there is a file named test , there is only one line on test ,haha
tiger@debian:~$ cat test
haha
tiger@debian:~$ cat 'test'
haha
Why the following command can not get haha?the ls test output test,why ls test | cat can not output haha?
tiger@debian:~$ ls test
test
ls test | cat
test
my system is debian+bash
You can have a look at ‘man cat’
When using
cat testorcat 'test', the shell assumes that the second argument is always a file name.However, with pipeline, cat expects to get a bunch of text, therefore, the content of ‘ls’ is printed.