Comment on How do I "ls -R | cat | grep print" ?
sighofannoyance@lemmy.world 10 months agoSo I could use something like grep string -R * to find any occurrence of the string in any files in the folder and sub-folders.
thank you!
Comment on How do I "ls -R | cat | grep print" ?
sighofannoyance@lemmy.world 10 months agoSo I could use something like grep string -R * to find any occurrence of the string in any files in the folder and sub-folders.
thank you!
JoeyJoeJoeJr@lemmy.ml 10 months ago
grep -r string .
The flag should go before the pattern.
-r
to search recursively,.
refers to the current directory.Why use
.
instead of*
? Because on it’s own,*
will (typically) not match hidden files. See the last paragraph of the ‘Origin’ section of: en.m.wikipedia.org/wiki/Glob_(programming). Technically yourls
command (lacking the-a
) flag would also skip hidden files, but since your comment mentions finding the string in ‘any files,’ I figured hidden files should also be covered (thefind
commands listed would also find the hidden files).