问题描述
|
我有这个,但是当我运行shell.sh脚本时,它说的是第15行:语法错误:文件意外结束。有人知道吗?
Shell.sh:
if [ $# -eq 0 ] ; then
echo \"parameters don\'t exist\"
else
for i in $@
do
awk -f scen.awk test.c | while read functie # test.c - name of the source program
do
#echo $function
grep -n \"$function\" test.c # test.c - name of the source program
nr=`grep -c $function`
echo $nr
done
done
fi
Scen.awk:
BEGIN { level=0; }
{
if (index($0,\"{\")<1)
{if ((level==0) && (index($0,\"(\")>0) && (index($0,\")\")>0))
{split($0,a,\"(\"); # we cut until \'(\'
split(a[1],b,\" \");
n = 1;
for (i in b) n++;
print b[n-1]; # the name of the function is the last component of the array b
}
if (index($0,\"{\")>0)
leveL++;
if (index($0,\"}\")>0)
level--;
}
}
解决方法
要解决它,请看第6行:
如果[$#-eq 0];然后
回显“参数不存在”
其他
为我$ @
做
awk -f scen.awk test.c |同时读取功能#test.c-源程序的名称
做
#echo $ function
grep -n \“ $ function \” test.c#test.c-源程序的名称
nr =
grep -c $function
回声$ nr
做完了
做完了
科幻
但是看来awk文件中还有其他问题。我将尝试看看。
希望能帮助到你。