I can do:

mkdir messages

and then:

touch messages/hello.txt

Is there a command that will do both - create the directory if it doesn't exist, and then the empty file? Something like:

touch -p messages/hello.txt
link|improve this question
feedback

1 Answer

up vote 2 down vote accepted

Not with anything in coreutils, but here's a bash function for that:

mktouch() {
  mkdir -p "$(dirname "$1")"
  touch "$1"
}
link|improve this answer
thank you for your answer – deb May 10 '10 at 13:56
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.