Reputation: 3307
I'm creating a list of file-names using the command:
ls | grep "\.txt$"
I'm getting a list of files:
F1.txt
F2.txt
F3.txt
F4.txt
I want to view the content of these files (using less / more / cat /...)
is there a way to do this by pipping?
(Btw, I got a list of file-names using a more complex command, this is just a simpler example for clarification)
Upvotes: 0
Views: 81
Reputation: 188114
Would this be enough?
$ cat *txt
For richer queries, you could use find
and xargs
:
$ find . -name "*txt" | xargs cat
Upvotes: 1
Reputation: 1665
you can try something like this:
#!/bin/bash
for i in *.txt
do
echo Displaying file $i ...
more $i
done
Upvotes: 1