Home > database >  Linux find command get all text in the file and print file path
Linux find command get all text in the file and print file path

Time:12-16

I need get all the texts in the matching file in the folder , however at the same time need to get the matching file path as well . Can you please advise , how can I get the matching file path as well using below command

find . -type f -name release.txt | xargs cat

CodePudding user response:

try find . -type f -name release.txt -exec grep -il {} \; | xargs cat

CodePudding user response:

Skip xargs, just do:

find . -type f -name release.txt -exec sh -c 'echo "$1"; cat "$1"' _ {} \;
  • Related