to be more specific ,I want to display contents of files from output of find
command,I tried the following commands but they don't get my work done
cat < find . -name "*.txt"
find . -name "*.txt" | cat
Either
find . -name "*.txt" | xargs cat --
or (better, if you have GNU find
)
find . -name "*.txt" -print0 | xargs -0 cat --
or
find . -name "*.txt" -exec cat -- {} +
cat --
to prevent unwanted file option matches.
Commented
Nov 24, 2017 at 9:34
find
start with .
?
Commented
Nov 24, 2017 at 13:47
You can use below the below command to display contents of files
Method 1:
find . -type f -iname "*.txt" -exec cat {} \;
Method 2:
ls -ltr *.txt | awk '{print "cat" " " $9}' | sh
ls
behaves very differently on different OSs. Second building shell scripts on the run is a little bit of over doing it.
Commented
Nov 24, 2017 at 9:37