Newby Question FC4

rengland at europa.com rengland at europa.com
Wed Jan 18 18:31:50 UTC 2006


> chalonec wrote:
>> I have installed FC4 and am looking for a command line way to search all
>> files in all directories and sub-directories on a disk for files that
>> contain a certain text string such as the word gateway or mode or any
>> word. There are so many config files on Linux that if I had this
>> capability I could find out which one had the information I needed so I
>> could then begin to identify where I might want to look to fix or
>> troubleshoot something other than the log files.  If this were Windows,
>> I would just use the text search string gui by right-clicking start.
>>
>> I have tried find, grep, locate, egrep, man, and the Internet and have
>> had varying levels of success but none seem to be consistent.  There are
>> a dizzying number of options,
>>
>> I am pretty sure grep or find should work but I can't figure out how.
>>
>> Can someone help ?
>
> A case-insensitive search for the word 'gateway' in directory /etc and
> all subdirectories:
>
> $ grep -i -r 'gateway' /etc
>
> Paul.
>
> --
> fedora-list mailing list
> fedora-list at redhat.com
> To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
>
>

But the OP is looking for a specific string in a file in the directory
structure.  I believe what is wanted is:

find . -exec grep -i -l  gateway {} \;

This will search from where you are in the directory structure (.) in a
case insensitive manner (-i) and return the file name only  (-l).  The {}
are correct, as is the \;  (backslash semicolon).  Include them as is and
modify the string "gateway" as needed.

~~R




More information about the fedora-list mailing list