• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

Searching for string in wildcard search

I'm try to do a search for a substring (i.e. 'transaction') in any file in a mount point.  For example, I'd like it to look through each file in the directory and show which file has the word 'transaction' in it.  Is there an easy way to do this?
0
slim7
Asked:
slim7
  • 2
  • 2
1 Solution
 
Kent OlsenData Warehouse Architect / DBACommented:

find <directoryname> -name '*transaction*'


Good Luck,
Kent
0
 
slim7Author Commented:
Actually i'm looking for the word 'transaction' within the file.  I think the 'find' works searches the file name.
0
 
Kent OlsenData Warehouse Architect / DBACommented:

Sorry.

grep -r transaction /path/*


Kent


0
 
slim7Author Commented:
our unix box doesn't recognize the -r,  I tried egrep -i 'transaction' * and that seemed to work.  what's the difference between grep and egrep?
0
 
TintinCommented:
If you want to search subdirs, do:

find /some/dir -type f -exec grep -li transaction {} \;

or if there are lots of files to search

find /some/dir -type f | xargs grep -il transaction

otherwise (as you've discovered), you can do

grep -i transaction *

Note that I've used the -l flag in the above examples, as this will list just the filename if the pattern is found, rather than display the lines it matches.

Difference between grep and egrep is that egrep supports extended regular expressions).

The -r flag is only available with GNU grep (found on all Linux systems).
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now