I have an account number 1234-5678, I am trying to find it in all files of directories. I used the below command but no result found.
grep "1234-5678" */
Please can someone help me how to find it in all files of directories.
I have an account number 1234-5678, I am trying to find it in all files of directories. I used the below command but no result found.
grep "1234-5678" */
Please can someone help me how to find it in all files of directories.
Portably/standardly:
find . -type f -exec grep 1234-5678 /dev/null {} +
Some grep implementations have -r or -R options to search in files recursively. The behaviour varies from implementation to implementation though.
With the grep found in AIX 6.1 for instance, you'll probably want to use the -R option1.
Beware though that contrary to the find approach above, it may look in non-regular files like fifos or device files (or may not, I don't have access to an AIX system just now).
1 Support for those -r/-R options was added in AIX 5.3 according to IBM's online documentation. And it should be noted that the meaning of -r/-R is the reverse from that of GNU grep (-r follows symlinks to directories, and -R doesn't while it's the contrary with GNU grep)
grep "1234-5678" * -r or grep "1234-5678" * -R if you want to follow the symbolic links.
-. It will also exclude hidden files and dirs in the current directory, but not in sub-directories.
– Stéphane Chazelas
Apr 01 '15 at 12:27
-r, --recursiveswitch ofgrep. – FloHimself Apr 01 '15 at 12:22grep "1234-5678" * -rorgrep "1234-5678" * -R– Milind Dumbare Apr 01 '15 at 12:23grep -Rsearches in fifos, devices or the target of symlinks?mkdir X; ln -s /etc/issue X/a; mkfifo X/b; grep -R . Xand see if it hangs or matches on /etc/issue. – Stéphane Chazelas Apr 01 '15 at 13:02grep -Ris not working on my machine – Aravind Apr 01 '15 at 13:15AIX 5.2– Aravind Apr 01 '15 at 13:32