I'm a beginner to shell scripts, and wrote below script but it keeps returning that "done" is not recognized token.
I know this is a super simple script, but I am too novice to debug this.. could anyone explain why this is not working? Thanks!
#!/bin/sh
for file in `ls`
do
if [ -f $file ]
echo $file + " exists"
fi
done
comment: added fi, but still has an error: syntax error near unexpected token `fi'
$file + " exists"will output what you expect, as it will print a literal "+" sign. You can simply write:echo $file exists. Or, if you want to make the message more explicit:echo "$file exists".