Reputation: 1
In linux bash terminal, the command I want to run is of the form: cmd | cmd2 > somefile.txt
.
However, I also want error message in cmd to be shown in terminal screen. So this is different from redirecting stderr to stdout. What is the way to do this?
Upvotes: 0
Views: 1192
Reputation: 691
Error messages written to standard error will not be sent to the piped command. I mean if your command is:
cmd | cmd2
then only the stdout
messages from cmd
will be piped to cmd2
and not stderr
messages.
Here is an example I used. I tried cat
ing a non-existing file and tried grep
ing some text:
$ cat non-existing-file.txt | grep something > grepped-text.txt
cat: non-existing-file.txt: No such file or directory
Upvotes: 2