|
Prev: Can sed match a choice of two?
Next: Comparing Files
From: pk on 24 Apr 2008 10:36 On Thursday 24 April 2008 16:17, apogeusistemas(a)gmail.com wrote: > I need find all occurences of alter, modify and replace in all files, > how could I make this ? If you want just this (and I think you don't, at least interpreting your previous post), then you can do find /src/dir -type f -exec egrep 'alter|modify|replace' '{}' \; If you need to do more things or something else, you have to be more precise in specifying what you want. -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome.
From: apogeusistemas on 24 Apr 2008 11:03 On Apr 24, 11:36 am, pk <p...(a)pk.invalid> wrote: > On Thursday 24 April 2008 16:17, apogeusiste...(a)gmail.com wrote: > > > I need find all occurences of alter, modify and replace in all files, > > how could I make this ? > > If you want just this (and I think you don't, at least interpreting your > previous post), then you can do > > find /src/dir -type f -exec egrep 'alter|modify|replace' '{}' \; > > If you need to do more things or something else, you have to be more precise > in specifying what you want. > > -- > All the commands are tested with bash and GNU tools, so they may use > nonstandard features. I try to mention when something is nonstandard (if > I'm aware of that), but I may miss something. Corrections are welcome. Is there any ls command to show me complete file´s pathname ? How could I get this ? Thank you.
From: Bill Marcum on 24 Apr 2008 11:15 On 2008-04-24, apogeusistemas(a)gmail.com <apogeusistemas(a)gmail.com> wrote: > > > Is there any ls command to show me complete file�s pathname ? > > How could I get this ? > Use find.
From: pk on 24 Apr 2008 11:22 On Thursday 24 April 2008 17:03, apogeusistemas(a)gmail.com wrote: >> find /src/dir -type f -exec egrep 'alter|modify|replace' '{}' \; > Is there any ls command to show me complete file´s pathname ? > > How could I get this ? There are at least two options. You can add the (nonstandard) -H option to egrep in the above command. You can use the -l option instead, but this prints only the filename (not the matching lines). Or, as Janis suggested, just have find return the list of files and use xargs to pass the list to grep. This way, grep automatically prints the name of the file. If you have lots of files, the latter option is probably more efficient. Beware of files with spaces or strange characters in their name. -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome.
From: pk on 24 Apr 2008 11:36
On Thursday 24 April 2008 16:32, mallin.shetland wrote: > apogeusistemas(a)gmail.com scrisse: > >> I need find all occurences of alter, modify and replace in all files, >> how could I make this ? > > grep -R -e alter -e modify -e replace * Depending on your shell, this may not catch hidden files and directories at the first level. Also, using -F /might/ be more efficient. -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome. |