Originally Posted by T3RM1NVT0R
2 is exit code. What I am doing here is telling the system if there is anything which has got exit status / code (2) in the output then redirect that to /dev/null
You have different exit codes like:
0 = success
1 = warning
2 = errors
Sorry, but I think you may be incorrect. Those are not exit codes, they refer to output streams
. 1 refers to stdout, and 2 refers to stderr. If you do no redirection, both outputs will go to your terminal. By using "2> /dev/null", you are redirecting the second output stream (stderr) to /dev/null instead of your terminal.
du outputs the file sizes to stdout and any errors to stderr. So if you were to do "du -sh /* 1> /dev/null" you will only see the output of stderr.
Exit codes are returned by the program when they exit, but you usally don't see it. Usually, an exit code of 0 indicates that there were no problems. A non-zero value indicates a problem. Every program defines its own exit codes for specific errors (the man page for that program usually has more details on this).