I would like my script ends working if a specific file is not found. Therefore I write the following:
[ -f "$DAEMON" ] || (echo "File $DAEMON not found" && exit 0)
But it doesn't work properly. If the file doesn't exist, my script outputs this error message and continues working.
I tried
[ -f "$DAEMON" ] || { echo "File $DAEMON not found" && exit 0 }
(as it is suggested here exit doesn't work in bash ), but I got syntax error (unexpected end of file).
[ -f "$DAEMON" ] || exit 0 works well but [ -f "$DAEMON" ] || (exit 0)
doesn't.
How can I output error message and stop script executing?