?
Solved

Searching for string in wildcard search

Posted on 2005-03-29
5
Medium Priority
?
261 Views
Last Modified: 2010-04-21
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
Comment
Question by:slim7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 13656756

find <directoryname> -name '*transaction*'


Good Luck,
Kent
0
 

Author Comment

by:slim7
ID: 13656952
Actually i'm looking for the word 'transaction' within the file.  I think the 'find' works searches the file name.
0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 13657090

Sorry.

grep -r transaction /path/*


Kent


0
 

Author Comment

by:slim7
ID: 13657154
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
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 13657189
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question