Hi All,
Can some one please explain the below code. Especially the %,* How it renaming the files and removing last field
for file in *.gz.*
do
echo mv $file ${file%\.*}
done
i/p
abcd.gz.20151011.1
o/p
abcd.gz.20151011
Hi All,
Can some one please explain the below code. Especially the %,* How it renaming the files and removing last field
for file in *.gz.*
do
echo mv $file ${file%\.*}
done
i/p
abcd.gz.20151011.1
o/p
abcd.gz.20151011
Yes, that's a "Parameter Expansion / Remove matching suffix pattern".
man bash
:
Hello nag_sathi,
This is called "parameter expansion" see following from documentation.
Here is the link for understanding parameter expansion too.
Shell Parameter Expansion (Bash Reference Manual)
I hope this helps.
Thanks,
R. Singh
Further notes:
"$file" "${file%.*}"
--
(end of options) after mv