rm -rf !(*.txt) 终端不报错为什么在脚本中会报错?
在终端中执行rm -rf !(*.txt),成功删除.txt以外的文件,但是把这句放在脚本中,会报错。
LOCATION=/export/home/byang/Test
if [ -d $Location ]; then
cd $Location
LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH
ls *.zip > a.asc
if test -s a.asc; then
cat a.asc | while read line
do
echo $line
cd $LOCATION
7za e $line -y
done
fi
cd $LOCATION
pwd
sleep 10
rm -rf !(*.txt)
rm *Summary.txt
fi
报错信息为:
$ ./test.sh
./test.sh: line 19: syntax error near unexpected token `!(*'
./test.sh: line 19: `rm -rf !(*.txt)'
不懂为什么会报错?要怎么修改?