Hi Guys ,
I want create files Dire and Sub Dire. as same time using variable.
EX:
x1="/hk/Pt/put/NC/R1.txt"
x2="/hk/pt/Put/Ot/NC/RN.txt"
And i want delete all after done with my script.
Thanks
Hi Guys ,
I want create files Dire and Sub Dire. as same time using variable.
EX:
x1="/hk/Pt/put/NC/R1.txt"
x2="/hk/pt/Put/Ot/NC/RN.txt"
And i want delete all after done with my script.
Thanks
mkdir -p ./`dirname $x1`; touch .`dirname $x1`/`basename $x1`
To remove: rm -rf ./hk
Just take away the 'echo'. The cleanup only remove the directory if it is empty, to be on the safe side
#! /bin/sh
function cleanup()
{
_x=$1
while [ "${_x%/*}" != "" ]
do
echo rmdir "${_x%/*}"
_x="${_x%/*}"
done
}
x1="/hk/Pt/put/NC/R1.txt"
x2="/hk/pt/Put/Ot/NC/RN.txt"
echo mkdir -p "${x1%/*}" "${x2%/*}"
cleanup "$x1"
cleanup "$x2"