当我运行我的脚本时,我收到了这个错误:
234.sh: line 3: syntax error near unexpected token `do
234.sh: line 3: `for folder in $array ; do
我没有看到错误。帮助?
#!/bin/bash
base=$(pwd)
array=`find * -type d`
for folder in $array ; do
cd $folder ;
grep -n $1 * | while read line ;
do name=$(echo "$line" | cut -f1 -d:) ;
if [ "$name" == "1234.sh" ]; then
continue ;
else
string=$(echo "$line" | cut -f2 -d:) ;
a=$(expr $string - 10)
if [ $a -lt 1 ] ; then
a=1 ;
fi ;
b=$(expr $string + 10) ;
echo "-----------------------"
echo $name:$a
sed -n $a,${b}p $name;
fi ;
done
cd $base ;
done