The whole content of the script I used is:
for code_file in ${*:?"Specify input file(s)"}
do
echo "Processing file $code_file ..."
temp_file=$code.tmp
awk '
$1=="subroutine" {
print "#ifdef sub" $2;
}
{
print $0;
prv_statement = new_statement;
new_statement = $1;
}
$1=="end" && prv_statement == "return" {
print "#endif";
}
' $code_file > $temp_file
if [ $? -eq 0 ]
then mv $temp_file $code_file
else echo "Failed !!!"
fi
done
exactly the same as yours. I saved the above script as awk.txt and change it to executable, then type ./awk.txt. It still has the error information as before: line 2 syntax error near unexpected token 'do.
Is there any format requirement on script? like in makefile, the command must start with a Tab.
I don't understand why.
Quote:
Originally posted by aigles
The error must be in the for statement.
Show us your modification.
Restor as posted, and execute the script with the input filename(s) as argument.
${*:?"Specify input file(s)"}
Substitute argument passed. If no argument on command line then print the error message "Specify input file(s)"
|