KE Liew wrote:
Hi,

Would be good to have an option to create a directory when using touch.

Rather than mkdir -P /path/to/wherever && touch /path/to/wherever/filename
It's nicer to have touch -P /path/to/wherever/filename

(in .bash_profile)
touch() {
  if [ $# -ne 1 ] || [ "${1:0:1}" = "-" ] ; then
    command touch "$@" # assume you know what you are doing
  else
    local d="${1%/*}"
    [ "$d" != "$1" ] && mkdir -p "$d"
    touch "$1"
  fi
}

...or you could re-write it to only do the 'special' logic if $1==-p && $# -eq 2

--
Matthew
"Resistance is futile" -- Borg
"No, resistance is the reciprocal of conductance" -- Dave Korn



_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to