hi,
can any one explain the below command. run it and see and if you understand please tell me.
File=s1_abc.txt.xls.pdf
MOD_File=$(echo ${File%.*}_`date +%Y%m%d_%H%M%S%N`.${File##*.})
i asked somedays before and got the above code. i needed to add date time stamp just before the last extension of the filename.
if i use the below command, it removes the last extension from the filename
echo ${File%.*}
output is:
s1_abc.txt.xls
if i use echo ${File%.*.*}
, it removes the last two extensions
output is:
s1_abc.txt
echo ${File##*.}
gives me the last extension i.e. pdf
echo ${File#*.}
gives me all the extension i.e. txt.xls.pdf
how the above command works especially %
and #