Hacker Newsnew | past | comments | ask | show | jobs | submit | binaryghost's commentslogin

#make intermediate directories and touch a file all at once

#e.g. mktouch ~/Desktop/test/file.md would make the test dir if it didn't exist then touch file.md inside of it

mktouch() {

    if [ $# -lt 1 ]; then
        echo "Missing argument";
        return 1;
    fi

    for f in "$@"; do
        mkdir -p -- "$(dirname -- "$f")"
        touch -- "$f"
    done
}


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: