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
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" | catEither
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 -- {} +
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.
– Raphael Ahrens
Nov 24 '17 at 09:37
cat $(find ...)– Videonauth Nov 24 '17 at 04:07cat --to prevent unwanted file option matches. – Raphael Ahrens Nov 24 '17 at 09:34findstart with.? – don_crissti Nov 24 '17 at 13:47xargsyour second comment to @Videonauth applies. – Raphael Ahrens Nov 24 '17 at 16:15