Is there a flag/option for touch
, mkdir
, >
, or some other command that will allow me to create a file and any non-existent parent directories at the same time?
For instance, let's say I'm in an empty folder. Now I can create parent directories if they don't exist when creating a folder
mkdir -p nested/folder
I can create files in existing directories
touch nested/folder/something.txt
But I can't create a file in a directory that doesn't exist yet
touch nested/folder/deep/more.txt
touch: cannot touch ‘nested/folder/deep/more.txt’: No such file or directory
How would I create that deep
folder at the same time I create more.txt
?
cat
and responses below proved helpful A little more info aboutmkdir -p
linfo.org/make_directory_tree.html