I learn that pipe (|) is used to pass stdout into subshell's stdin.
But, command less must have filename argument like less file1.txt
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.
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.
lesswill accept a filename, but if no file is given, it reads fromstdin. That is specific to thelesscommand so not relevant totr. Pipes in general are implemented as a special type of file called "FIFO" (first in first out) which is temporarily created by the shell to allow one command to read what another command outputs. In a simple two command pipeline, thestdoutof the first command is directed to the FIFO (write-only), and thestdinof the second command is directed from the FIFO (read only). But you can pretend the first command writes directly to the second.lesswithout file argument(for example, justless), it doesn't takestdinfrom keyboard. Is it just internal mechanism from less?less(1)takes commands from the keyboard, taking input from there simultaneously makes no sense. Other programs that don't take commands just don't care to check.