Skip to main content
added 114 characters in body
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k

This may be done through

find dir -type f -exec grep -H '+ ID$' {} +

This will find all regular files in or beneath the directory dir and then run grep -H '+ ID$' in batches of as many as possible of these. The result will contain both the filename of the file matching the regular expression and the lines from the file that matched.

To only get the filenames, use -l in place of -H with grep, and to only get the lines that match, use -L instead.

The regular expression + ID$ will match any line in a file that contains the exact string + ID at the very end of the line.

Or, without find but with a grep that is able to recurse into subdirectories:

grep -R '+ ID$' dir

On systems that have a grep that does not do -H (this is a non-standard option), you may instead use

find dir -type f -exec grep '+ ID$' /dev/null {} +

If you just want the matching lines (and no file names) on a system like this, cat the files together and grep that:

find dir -type f -exec cat {} + | grep '+ ID$'

This may be done through

find dir -type f -exec grep -H '+ ID$' {} +

This will find all regular files in or beneath the directory dir and then run grep -H '+ ID$' in batches of as many as possible of these. The result will contain both the filename of the file matching the regular expression and the lines from the file that matched.

To only get the filenames, use -l in place of -H with grep, and to only get the lines that match, use -L instead.

The regular expression + ID$ will match any line in a file that contains the exact string + ID at the very end of the line.


On systems that have a grep that does not do -H (this is a non-standard option), you may instead use

find dir -type f -exec grep '+ ID$' /dev/null {} +

If you just want the matching lines (and no file names) on a system like this, cat the files together and grep that:

find dir -type f -exec cat {} + | grep '+ ID$'

This may be done through

find dir -type f -exec grep -H '+ ID$' {} +

This will find all regular files in or beneath the directory dir and then run grep -H '+ ID$' in batches of as many as possible of these. The result will contain both the filename of the file matching the regular expression and the lines from the file that matched.

To only get the filenames, use -l in place of -H with grep, and to only get the lines that match, use -L instead.

The regular expression + ID$ will match any line in a file that contains the exact string + ID at the very end of the line.

Or, without find but with a grep that is able to recurse into subdirectories:

grep -R '+ ID$' dir

On systems that have a grep that does not do -H (this is a non-standard option), you may instead use

find dir -type f -exec grep '+ ID$' /dev/null {} +

If you just want the matching lines (and no file names) on a system like this, cat the files together and grep that:

find dir -type f -exec cat {} + | grep '+ ID$'
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k

This may be done through

find dir -type f -exec grep -H '+ ID$' {} +

This will find all regular files in or beneath the directory dir and then run grep -H '+ ID$' in batches of as many as possible of these. The result will contain both the filename of the file matching the regular expression and the lines from the file that matched.

To only get the filenames, use -l in place of -H with grep, and to only get the lines that match, use -L instead.

The regular expression + ID$ will match any line in a file that contains the exact string + ID at the very end of the line.


On systems that have a grep that does not do -H (this is a non-standard option), you may instead use

find dir -type f -exec grep '+ ID$' /dev/null {} +

If you just want the matching lines (and no file names) on a system like this, cat the files together and grep that:

find dir -type f -exec cat {} + | grep '+ ID$'