SyntaxFix
Write A Post
Hire A Developer
Questions
Here is an alternative method using ls:
ls
(ls x.txt && echo yes) || echo no
If you want to hide any output from ls so you only see yes or no, redirect stdout and stderr to /dev/null:
stdout
stderr
/dev/null
(ls x.txt >> /dev/null 2>&1 && echo yes) || echo no