Escaping special characters and & in awk

The awk command will accept escaped special characters that may be required in an output.
Rename the following file by removing all the characters after the three character file extensions.
ls *\?* | awk -F . '{print "mv \""$0"\" " $1".zip"}'

This awk command will work for files that have common extension. To complete command and rename the files in same line, try

ls *\?* | awk -F . '{print "mv \""$0"\" " $1".zip"}' | sh<

Leave a comment

Your comment