Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recursively find all files containing 'string.txt' in file name [duplicate]

Tags:

linux

grep

bash

I want to recursively search for all files and sub-directories within a directory with sub string within file name as 'string.txt'

My command:

   cd /home/abcd/dir
   grep -R "*rate-trace.txt" | wc -l
like image 376
TjS Avatar asked Dec 17 '25 08:12

TjS


1 Answers

grep is searching the file's content.

Use find command instead:

find /home/abcd/dir -type f -name "*rate-trace.txt" | wc -l

OR

cd /home/abcd/dir
find . -type f -name "*rate-trace.txt" | wc -l
like image 146
Jay jargot Avatar answered Dec 20 '25 00:12

Jay jargot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!