So I\'ve got the following files in the tmp directory:
file.0
file.1
file.t9
file.22
file.4444
if I wanted to list only the files that
Another simple solution to just prevent seeing (ie hide) "ugly errors" is to redirect standard error to /dev/null
by appending 2> /dev/null
. In your example:
ls tmp/file.{[0-9],[0-9][0-9],[0-9][0-9][0-9],[0-9][0-9][0-9][0-9]} 2> /dev/null
This would give you the results you want and hide any errors. Works with any linux command or executable that sends output to stdout and errors to stderr. Note that this does not affect the command return status ($?
), it just suppresses errors.