So I'm learning about pipes in bash and I found this pithy description:
A Unix pipe connects the STDOUT (standard output) file descriptor of the first process to the STDIN (standard input) of the second. What happens then is that when the first process writes to its STDOUT, that output can be immediately read (from STDIN) by the second process.
Given this understanding, let's connect the STDOUT of printf
to the STDIN of ls
. For simplicity, print the parent directory (printf ..
).
~/Desktop/pipes$ mkdir sub
~/Desktop/pipes$ ls
sub
~/Desktop/pipes$ cd sub
(no files)
~/Desktop/pipes/sub$ printf .. | ls
(no files)
~/Desktop/pipes/sub$
I want to be doing: ls ..
but it seems that all I'm getting is ls
. Why is this so? How can I ls
the parent directory using pipes? Am I misunderstanding pipes?