I have a directory with some files -
mkdir _tmpmm
touch a1 b2 c3 d4
ls
# a1 b2 c3 d4
When I grep for a on the output of ls, I see only the file a1 - although the ls output is showing 4 files on the same line
ls | grep a
# a1
However, if I create a file named "file_with_names.txt" containing the following lines -
cat file_with_names.txt
# a1 b2 c3 d4
# xxx
# zaz
And then do either
grep a file_with_names.txt
OR
cat file_with_names.txt | grep a
I get -
# a1 b2 c3 d4
# zaz
So, my question is - why does grepping for a on the ls output not return the full line - i.e. a1 b2 c3 d4?
ls; there's better ways. – Marcus Müller Nov 22 '21 at 11:39