Linux CLI - Pipes and Redirection
What will be the output of this command?
grep 'pattern' /nonexistentfile > /dev/null 2>&1 && echo 'Found' || echo 'Not Found'
grep 'pattern' /nonexistentfile > /dev/null 2>&1 && echo 'Found' || echo 'Not Found'
grep will fail and return a non-zero exit status./dev/null, so no messages appear.&& runs echo 'Found' only if grep succeeds; otherwise, || runs echo 'Not Found'.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions