STDERR
This stream has value 2 and it will be used as 2>.
ls video.mp4 2> error.txt
If video.mp4 is not present in your file directory then you will get an error-
ls: cannot access 'video.mp4': No such file or directory
and this error will be saved to a new file error.txt.
If you want to append the errors in an existing file then you must use 2>>.
if you want to save output and error both then you can do this like
ls -l video.mp4 file.txt > myoutput 2>&1
video.mp4 is not in your system and file.txt is inside your home directory. so whenever you will run above code. it will make a new file myoutput and save the error as well as output in file named myoutput.
Comments
Post a Comment