Hello guys,
This is an executable shell program that I want to execute, but it doesn't execute and gives error. The shell program that I want to execute is taken from a well-reputed book on Solaris 10.
Here is the program
#!/usr/bin/bash
if test -a $1 then
echo "Number of lines in file " $1
wc -l $1
else
echo "The file" $1 "does not exist"
fi
And here is the error
-bash-3.00$ ./test.sh /etc/passwd
./test.sh: line 5: syntax error near unexpected token `else'
./test.sh: line 5: `else'
Could you please figure out what causes the error.
And what is the function of $1 in these shell programs. Please pardon me as I am new to unix shell programming.