Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grep: warning: recursive directory loop

Tags:

grep

unix

I'm using Xshell to ssh an Unix server, and I'm trying to search for files containing specific text..

The command I'm using is: grep -ilr "blah_blah_text" ./

It found what I was looking for, but it also gave these warnings:

grep: warning: ./svn/pages/dvorak/xhtml/mh370/ocean/dvorak/found: recursive directory loop

grep: warning: ./svn/pages/dvorak/xhtml/mh370/ocean/dvorak/testing/sea: recursive directory loop

grep: warning: ./svn/pages/dvorak/xhtml/mh370/ocean/dvorak/testing/found: recursive directory loop

grep: warning: ./svn/pages/dvorak/xhtml/mh370/ocean/testing/dvorak/found: recursive directory loop

grep: warning: ./svn/pages/dvorak/xhtml/mh370/ocean/testing/dvorak/monday: recursive directory loop

grep: warning: ./svn/pages/dvorak/xhtml/mh370/ocean/testing/found: recursive directory loop

grep: warning: ./svn/pages/dvorak/xhtml/mh370/testing/dvorak/ocean/sea: recursive directory loop

grep: warning: ./svn/pages/dvorak/xhtml/mh370/testing/dvorak/ocean/monday: recursive directory loop

grep: warning: ./svn/pages/dvorak/xhtml/mh370/testing/dvorak/monday: recursive directory loop

grep: warning: ./svn/pages/dvorak/xhtml/mh370/testing/ocean/dvorak/found: recursive directory loop

grep: warning: ./svn/pages/dvorak/xhtml/mh370/testing/ocean/dvorak/monday: recursive directory loop

grep: warning: ./svn/pages/dvorak/xhtml/mh370/testing/ocean/monday: recursive directory loop

grep: warning: ./svn/pages/gulf/xhtml/qwerty/ocean/dvorak/found: recursive directory loop

grep: warning: ./svn/pages/gulf/xhtml/qwerty/ocean/dvorak/testing/sea: recursive directory loop

grep: warning: ./svn/pages/gulf/xhtml/qwerty/ocean/dvorak/testing/found: recursive directory loop

grep: warning: ./svn/pages/gulf/xhtml/qwerty/ocean/testing/dvorak/found: recursive directory loop

grep: warning: ./svn/pages/gulf/xhtml/qwerty/ocean/testing/dvorak/monday: recursive directory loop

grep: warning: ./svn/pages/gulf/xhtml/qwerty/ocean/testing/found: recursive directory loop

grep: warning: ./svn/pages/gulf/xhtml/qwerty/dvorak/ocean/sea: recursive directory loop

grep: warning: ./svn/pages/gulf/xhtml/qwerty/dvorak/ocean/testing/sea: recursive directory loop

grep: warning: ./svn/pages/gulf/xhtml/qwerty/dvorak/ocean/testing/found: recursive directory loop

grep: warning: ./svn/pages/gulf/xhtml/qwerty/dvorak/testing/sea: recursive directory loop

grep: warning: ./svn/pages/gulf/xhtml/qwerty/dvorak/testing/ocean/sea: recursive directory loop

grep: warning: ./svn/pages/gulf/xhtml/qwerty/dvorak/testing/ocean/monday: recursive directory loop

grep: warning: ./svn/pages/india/xhtml/abcd/testing/dvorak/ocean/sea: recursive directory loop

grep: warning: ./svn/pages/india/xhtml/abcd/testing/dvorak/ocean/monday: recursive directory loop

grep: warning: ./svn/pages/india/xhtml/abcd/testing/dvorak/monday: recursive directory loop

grep: warning: ./svn/pages/india/xhtml/abcd/testing/ocean/dvorak/found: recursive directory loop

grep: warning: ./svn/pages/india/xhtml/abcd/testing/ocean/dvorak/monday: recursive directory loop

grep: warning: ./svn/pages/india/xhtml/abcd/testing/ocean/monday: recursive directory loop

grep: warning: ./svn/pages/india/xhtml/abcd/dvorak/ocean/sea: recursive directory loop

grep: warning: ./svn/pages/india/xhtml/abcd/dvorak/ocean/testing/sea: recursive directory loop

grep: warning: ./svn/pages/india/xhtml/abcd/dvorak/ocean/testing/found: recursive directory loop

grep: warning: ./svn/pages/india/xhtml/abcd/dvorak/testing/sea: recursive directory loop

grep: warning: ./svn/pages/india/xhtml/abcd/dvorak/testing/ocean/sea: recursive directory loop

grep: warning: ./svn/pages/india/xhtml/abcd/dvorak/testing/ocean/monday: recursive directory loop

What do these messsages mean?

like image 397
GrSrv Avatar asked Mar 21 '14 07:03

GrSrv


People also ask

How do I grep a recursive directory?

To recursively search for a pattern, invoke grep with the -r option (or --recursive ). When this option is used grep will search through all files in the specified directory, skipping the symlinks that are encountered recursively.

What is recursive grep?

Grep command is used to search text from files. It is a versatile pattern that invokes grep with –r. –R option search files recursively from subdirectories, starting from the current directory. The command is run from the top-level directory. For instance /home/abc etc.

Which command is used for search a string recursively in all directories?

You can use grep command or find command as follows to search all files for a string or words recursively.


1 Answers

You have to exclude symbolic links from your grep, they are reason of this warning. You should try to use find firstly:

find ./ -type f -exec grep -il "blah_blah_text" {} \;

When you use find firstly you can omit -r in grep, because find is already recursive.

like image 85
adamr Avatar answered Sep 26 '22 07:09

adamr