How can I eliminate syntax error in command line? I created a bash script like this:
#!/bin/bash
USER="$@"
sed s/[!@#$%^&*()]//g > $@
done
if ! [ -f $@ -a -r $@ ] ; then
echo "Wrong Option : "${USER}" is not readable or not exist" >&2
exit -1
fi
cat "${@}"|while read -r line
do
IFS=, read -r f1 f2 f3 f4 f5 <<< "$line"
mysql --user=user --password=password --database=database <<EOF
INSERT INTO table_name VALUES($f1, $f2 , $f3 , $f4 ,$f5);
EOF
done
并且我对其他终点站执行这一规定:
$ ./script.sh test!rr.txt
-bash: !rr.txt: event not found
Actually, this is a script which insert data from text files to database table. and as you can see, I want to check file existence before insert text files.
我试图利用tr——指挥和指挥,以消除指挥线上的yn误,但我认为这行不通。
我期望:
$ ./script.sh test!rr.txt
Wrong Option : test!rr.txt is not readable or not exist
Do you have any idea? Thanks.