0

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
iruvar
  • 16,725

2 Answers2

4

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 -- {} +
steeldriver
  • 81,074
-1

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
Zanna
  • 3,571
  • 1
    The second method has some issues. First 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