I know what I can do
mdkir -p a/b/c/d
However time and again I need to put the file in a new directory. So this is what i do
mkdir -p a/b/c touch a/b/c/foo.txt
I was wondering if there is an easy way to combine these two operations.
In Bash shell, create a function in your .bashrc file.
function mktouch { mkdir -p $( dirname $1 ) touch $1 }
Then just call mktouch a / b / c / foo.txt
In bash, you can do:
mkdir -p a/b/c && touch !#:2/foo.txt
But that's not exactly how I think you want it.