I learn that pipe (
|) is used to pass stdout into subshell's stdin.
less must have filename argument like
However, when I use command like
ls -l /root | less, it works.
So, I assumed that in this case, less takes
stdin file which is written from
ls -l /root's stdout. I mean, in real,
less stdin when less do its own command. But, because of another command, I got confused. It's
tr command doesn't take any file argument like
tr a-z A-Z file1.txt. It just take stdin from keyboard or redirected stdin. But, command
ls -l /root | tr a-z A-Z is possible. Then, what I assumed is wrong.
How pipe works in real? The basic is that pipe passes main shell's standard output into subshell's standard input. But, I can't know main shell's standard output goes to subshell's standard input file or just it takes situation that I enter the characters from keyboard. But, when I see above examples, shell takes both situations.