How to search by content on Ubuntu
You need to specify a file when using the grep
command. With the command you're using, you're searching in the standard input...
Try grep -r "test" directory
.
find / -name "*.txt" -exec grep "text here" {} \; -print 2>/dev/null
Which can be explained in human speak as:
- find
- starting from /
- in all files named *.txt (quotes are to bypass shell interpretation)
- with the resulting hits, perform the following
- grep "test here"
- in the file {}
- end of exec (\;) escaped end of statement
- print the files that match
- redirect error messages in sink (since you might not be root, otherwise just sudo it).