Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070509 Thunderbird/1.5.0.12 Mnenhy/0.7.4.0
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