There is no command available for creating a file and the parent directories in one step. Nevertheless you can help yourself with a simple bash script. Just add the following snippet to your ~/.bashrc.

mktouch() { mkdir -p $(dirname $1) && touch $1; }

Afterwards you can run this command like this: mktouch /home/demo/newdirectory/newfile1.txt

Source: https://unix.stackexchange.com/a/305850 -> Comments

Add your reply here with Webmention (you must link to this page in its canonical form)
Webmentions are approved manually. Will take some time until they show up.