I'm trying to do a simple script that unzips a zip file which has an exclamation mark in its name:
#!/bin/bash
UNZIP='/usr/bin/unzip'
CUT="/usr/bin/cut"
GREP="/usr/bin/grep"
FILENAME="test"
FILE="/usr/local/var/www/htdocs/"$FILENAME"\!3.zip"
UNZIPPEDFOLDER=$($UNZIP ${FILE} | $GREP -m1 'creating:' | $CUT -d' ' -f5-)
echo $UNZIPPEDFOLDER
but when script is being executed, unzip returns:
unzip: cannot find or open /usr/local/var/www/htdocs/test\!3.zip, /usr/local/var/www/htdocs/test\!3.zip.zip or /usr/local/var/www/htdocs/test\!3.zip.ZIP.
It works fine when there is no "!" sign in filename, but to make some of my work automated, I need to stay with original file names.