find/grep returns no matches

Hi all!

I've faced with very unintelligible error using find/grep like this:

root@v29221:~# find /var/www/igor/data/www/lestnitsa.ru | grep u28507

I get nothing as a result, but:

root@v29221:~# grep u28507 /var/www/igor/data/www/lestnitsa.ru/_var.inc               
$db_name = 'u28507';
$link = mysql_connect ('u28507.mysql.masterhost.ru', '*', '*') or die ("Could not connect");

It drives me crazy, please help to figure this out.

Hi.

You've taken the filename as input to grep, so you are grepping on the filename, not on the file contents, as you imagined.

try using

find ... | xargs grep u28507

or better

find ... | xargs -I{} grep u28507 {}
$ cat file1
start
  u28507
end

$ find . -name file1 | grep u28507                   

$ find . -name file1 | xargs grep u28507 
  u28507

$ find . -name file1 | grep file1 
./file1

Thank you very much! What a stupid mistake... :slight_smile: