DelphiFAQ Home Search:
General :: Linux :: shell
Linux shell programming/ scripting, shortcuts and general know-how.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Recursively find all documents that match a file name and contain a string


I need to recursively find all documents where the file name matches a certain pattern ('index*') and that contain a certain string ('update'). How do I do this in Linux?


You need a combination of find to locate those index* files and grep to only list those that have the keyword 'update' in it.

The following command will do the trick.

Note: if you want a 'negative search', meaning list all documents that do NOT contain 'update', then add the -v parameter to grep.

# -l lets grep just put out the filename
 find index* -exec grep -l update {} \;
 # -v does a negative search
 # show all documents that do NOT contain 'update'
 find index* -exec grep -l -v update {} \;

Generated 8:00:43 on Mar 21, 2018