A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

December 16, 2014

Unexpected token fi

Forums: 

I am trying to run my command but it comes up with this error:
syntax error near unexpected token `fi' on line 7.

Here is my command:

if [ $# -gt 0 ]
then
if [ $1 = head ] || [$1 = tail ]
then
$1 -n $3
else
fi
fi

if [ -d $3 ]
then
echo "Directory selected exists"
else
echo "Directory selected does not exist"
fi

if [[ $2 = *[[:digit:[[* [[;
then
echo "value is a digit"
else
echo "$2 is not an integer"
fi

Click Here!