Skip to main content
edited tags
Link
Moberg
  • 187
  • 11
added 44 characters in body
Source Link
Moberg
  • 187
  • 11

How can I find files that contain specific content (grepable) and sort the found files by last modified time? (I want to select just the one newest file)

This command finds files:

find subfolder/ -maxdepth 1 -type f -exec grep -l 'blue_wizards' {} \;`

This command finds files and sort them:

find subfolder/ -maxdepth 1 -type f -printf "%T+ %p\n" | sort

But if I supply -printf the input to -exec grep will be not what I want.

How can I find files that contain specific content (grepable) and sort the found files by last modified time?

This command finds files:

find subfolder/ -maxdepth 1 -type f -exec grep -l 'blue_wizards' {} \;`

This command finds files and sort them:

find subfolder/ -maxdepth 1 -type f -printf "%T+ %p\n" | sort

But if I supply -printf the input to -exec grep will be not what I want.

How can I find files that contain specific content (grepable) and sort the found files by last modified time? (I want to select just the one newest file)

This command finds files:

find subfolder/ -maxdepth 1 -type f -exec grep -l 'blue_wizards' {} \;`

This command finds files and sort them:

find subfolder/ -maxdepth 1 -type f -printf "%T+ %p\n" | sort

But if I supply -printf the input to -exec grep will be not what I want.

Source Link
Moberg
  • 187
  • 11

combine `find -printf` and `find -exec grep -l`

How can I find files that contain specific content (grepable) and sort the found files by last modified time?

This command finds files:

find subfolder/ -maxdepth 1 -type f -exec grep -l 'blue_wizards' {} \;`

This command finds files and sort them:

find subfolder/ -maxdepth 1 -type f -printf "%T+ %p\n" | sort

But if I supply -printf the input to -exec grep will be not what I want.