Unix administration - how to find which files have a specific string?

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > March 2004 > how to find which files have a specific string?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author how to find which files have a specific string?
Bing Du

2004-03-10, 10:36 am

Greetings,

RedHat 9.

When I used Solaris (7,8), I used the command 'mg' quite often for this
purpose. But I don't see 'mg' on RedHat.

Appreciate any help,

Bing

Davide Bianchi

2004-03-10, 10:36 am

Bing Du <bdu@iastate.edu> wrote:
> When I used Solaris (7,8), I used the command 'mg' quite often for this
> purpose. But I don't see 'mg' on RedHat.


If you mean 'a file that contains a specific string', use
grep for that.

Davide

--
| The only really decent thing to do behind a person's back is pat it.
|
|
|
Bing Du

2004-03-10, 11:34 am

Great. I've never used 'grep' recursively. Thanks much for the heads-up.

Bing

Davide Bianchi wrote:

> Bing Du <bdu@iastate.edu> wrote:
>
>
>
> If you mean 'a file that contains a specific string', use
> grep for that.
>
> Davide
>


Jeff Schwab

2004-03-10, 11:34 pm

Bing Du wrote:


Bing: When I used Solaris (7,8), I used the command 'mg' quite often
for this purpose. But I don't see 'mg' on RedHat.

Davide: If you mean 'a file that contains a specific string', use grep
for that.

Bing: Great. I've never used 'grep' recursively. Thanks much for
the heads-up.


Make "find" to do the recursion, and use find's "-exec" option to
run grep.

Doug Freyburger

2004-03-11, 10:38 am

Bing Du wrote:
>
> Great. I've never used 'grep' recursively.


man find looking for the -print and -type f switches.

man xargs to see how find turns any other program into using recursion.
Mark Daniels

2004-03-17, 4:41 pm

Example:

find / -exec grep "whatyourlookingfor" {} \; -print

Cheers,

Mark
hacker boy

2004-03-20, 10:37 am

find / -print | xargs grep "whateveryoulookinfer" -n -H $1


mdhmi@yahoo.com (Mark Daniels) wrote in message news:<7ee5b960.0403171222.6d170973@posting.google.com>...
> Example:
>
> find / -exec grep "whatyourlookingfor" {} \; -print
>
> Cheers,
>
> Mark

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com