I am new to scripting and using linux. The below script that I have written simply prints the passed arguments and does a check in if condition. But not sure why I keep getting 'if' unmatched error
echo "The number of arguments passed "
echo $#;
echo "The passed arguments are "
echo $@
count="$#"
echo "Count is "
echo $count;
if [[ $count -eq "2" ]]; then
echo "Correct";
else
echo "Incorrect";
fi
when I run script above as
$ ./MyScript "ABC" "XYZ"
Output ->
The number of arguments passed
: not found [No such file or directory]
2
The passed arguments are
: not found [No such file or directory]
ABC XYZ
: not found [No such file or directory]
Count is
: not found [No such file or directory]
2
syntax error 'if' unmatched