Not able to suppress the error message using /dev/null

Not sure why I am not able to suppress the error message after using /dev/null 2>&1

$ ll /home/harry/workbook/smoel | grep xyz > /dev/null 2>&1
ls: cannot access /home/harry/workbook/smoel: No such file or directory

Answer

The error comes from ls, not grep.

ll /home/harry/workbook/smoel 2>/dev/null | grep xyz

Leave a Reply

Your email address will not be published. Required fields are marked *