How do I get unix to search inside ALL files for a the string "hello"?
I've tried the following but it doesn't work:
sudo grep "hello" | find / -name "*" 2>/dev/null
Does anyone have any other ideas?
Thank you.
grep (GNU or BSD) You can use grep tool to search recursively the current folder, like: grep -r "class foo" . Alternatively, use ripgrep .
If you want to search multiple files, just append as many to the command as you'd like. You can also use wildcards in the commmand. The output from grep shows us which files the string was found in. To search recursively, use the -r option with grep .
Grep Command. grep is a built-in Linux command that prints lines that match a given pattern. It returns all the lines of a file that contain a certain string by default, and the command is also case-sensitive.
Maybe this one?
sudo cd / && grep -rn "hello" *
EDIT: the 'n' option of course is not needed - it simply displays the line numbers and I find it nice. The 'r' option tells grep to perform recursive search within directories.
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