How can you improve this code snippet?
if ls /etc/passwd &> /dev/null then echo "exists" fi
The ls command will output the name of the file to the screen. Running ls in quiet mode will improve the code snippet.
The redirect to /dev/null will silence the return code invalidating the conditional. Removing the redirect will solve this.
/dev/null
Use Bash's built-in [[ ]] test conditions instead of the ls command.
[[ ]]
The code snippet cannot be improved, this is a valid way of checking for the existence of a file.