What is the best way to get a list of files that contain a specific
string without printing the content?
Hello!
What is the best way to get a list of files that contain a specific
string without printing the content?
I can use find to select all files in a directory including subdirs and
I can use grep to filter it, but it prints the content.
Is there a better solution for that?
Hello!
What is the best way to get a list of files that contain a specific
string without printing the content?
I can use find to select all files in a directory including subdirs and
I can use grep to filter it, but it prints the content.
Is there a better solution for that?
Forget find, use grep -rl (or -Rl) (recursive, list)
Am 26.09.2023 um 16:57:45 Uhr schrieb Janis Papanagnou:
Yes - ...in case your grep has it. (It's non-standard.)
Mine has it.
[...]
Most Linux distributions ship GNU grep, some UNIX systems might have
other variants.
Forget find, use grep -rl (or -Rl) (recursive, list)
Yes - ...in case your grep has it. (It's non-standard.)
or if you have to find the files
find ...file-properties... | xargs grep -lF specific-string
It it's not a "specific string" but a regular expression pattern that
you want to match in the files then omit grep's F option, use just -l.
If filenames contain blanks and whatnot, add option -print0 to find
and -0 (this is a 'dash zero') to xargs.
Alternatively you may also use find's -exec option instead of xargs.
I note that grep also has the -q option to not print output.
Hello!
What is the best way to get a list of files that contain a specific
string without printing the content?
I can use find to select all files in a directory including subdirs and
I can use grep to filter it, but it prints the content.
Is there a better solution for that?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 498 |
Nodes: | 16 (2 / 14) |
Uptime: | 53:05:28 |
Calls: | 9,810 |
Calls today: | 12 |
Files: | 13,754 |
Messages: | 6,190,510 |