Sunday, January 01, 2012

How to redirect an error message in a linux terminal




To redirect an error message:

1) Fore the ls command to display an error message by giving it an invalid argument. Assuming you have no file or directory in your home directory named oops, type ls oops ENTER. You see the following error message:

ls: oops: No such file or directory

2) Redirect the error output of the ls command. Type ls oops 2> errfile ENTER. There is no output on the screen.

3) Type cat errfile ENTER. You see errfile's contents:

ls: oops: No such file or directory


No comments:

Post a Comment