2> Allows us to redirect standard error.
Taking advantage of
rm’s ability to not delete files recursively can come in handy, especially when writing clean up scripts, but it can be noisy when you don’t care.
Give this file structure:
I may want to delete all the files, but not touch the directories (to keep file removal simple)
$ rm *
rm: cannot remove 'do-not-delete': Is a directory
Because the directory error message comes over stderr, we can simply redirect it to
/dev/null to ignore it:
rm * 2> /dev/null