I am a relatively experienced user in Linux. I want to understand better when it makes sense to use the pipe in Unix/Linux.
According to all book references, pipe |
is used to connect commands together from left to right. When used with common commands such as ls
, ps
, echo
, it is simple to understand that the pipe works very well because the previous commands produce simply an output without opening things such as a buffer viewer (e.g. less
).
So if I execute ls | tr -d 'a'
, we all know things work. But if I execute top -n 1 | grep 'average'
, things start to come a little strange. In fact, if we use a screen oriented command left to the pipe, the pipe operator itself tries to redirect the output from that command and sometimes it is not easy to understand which kind of output redirects. I think this is due to a wrong usage of the pipe operator in such cases.
The question is: "When we should use the pipe operator and what happens if I try to use the pipe right to some commands like top and other screen oriented commands?"
Thank you.