From the Linux command-line you want to search a directory structure of files and return the paths to all files that contain a particular string. What command do you use? (Because we all need daily #Linux #DFIR #CommandLine #Trivia)
11
3
34
Props to 🐘feld@bikeshed.party for the first correct answer to yesterday's #Linux #DFIR #CommandLine #Trivia: "grep -rl string /path/to/files"
1
1
Honorable mention to 🐘PhilHagen@infosec.exchange for improving the answer with "rail grep": "grep -rail string /path/to/files". That will get you case-insensitive matching.
1
Interestingly, the "-a" and"-l" options are redundant here. "-a" normally gives you matching strings from non-ASCII files. But since we're only printing file names ("-l"), it doesn't matter.

Nov 11, 2022 · 12:40 PM UTC

1
1
We got several answers where people looked for a string in the file path rather than the file content. Props to JakubUrbanec for chiming in with: "find /path/to/files -iname "*string*"