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?
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.
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.
You can use grep command or find command as follows to search all files for a string or words recursively.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With