|
Prev: Can sed match a choice of two?
Next: Comparing Files
From: Stephane CHAZELAS on 24 Apr 2008 11:41 2008-04-24, 17:22(+02), pk: > 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 use: find /src/dir -type f -exec \ grep -E 'alter|modify|replace' /dev/null {} + The "+" should make it a lot faster as well. You don't need -E here, you could even do with -F: find /src/dir -type f -exec \ grep -F -e alter -e modify -e replace /dev/null {} + -- St�phane
From: Stephane CHAZELAS on 24 Apr 2008 11:44 2008-04-24, 17:36(+02), pk: > 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. A problem with most versions of grep that support the -R non-standard option is that it follows the symlinks (as if -follow was given to find). To avoid the problem with hidden files (or files whose name starts with "-" or if there are too many files for the E2BIG execve(2) limit), simply do: grep -FR -e alter -e modify -e replace . -- St�phane
From: apogeusistemas on 24 Apr 2008 11:47 On Apr 24, 12:44 pm, Stephane CHAZELAS <this.addr...(a)is.invalid> wrote: > 2008-04-24, 17:36(+02), pk: > > > On Thursday 24 April 2008 16:32, mallin.shetland wrote: > > >> apogeusiste...(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. > > A problem with most versions of grep that support the -R > non-standard option is that it follows the symlinks (as if > -follow was given to find). > > To avoid the problem with hidden files (or files whose name > starts with "-" or if there are too many files for the E2BIG > execve(2) limit), simply do: > > grep -FR -e alter -e modify -e replace . > > -- > Stéphane Thank You so much for your informations !!!
From: pk on 24 Apr 2008 11:55 On Thursday 24 April 2008 17:44, Stephane CHAZELAS wrote: > A problem with most versions of grep that support the -R > non-standard option is that it follows the symlinks (as if > -follow was given to find). (do you mean -L?) I understand that this may yield different results between find . ... | xargs grep and grep -R . ....but isn't following the symlinks the only sensible behavior for grep? Or maybe I did not understand what you mean. -- 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: Chris Mattern on 24 Apr 2008 12:11
On 2008-04-24, apogeusistemas(a)gmail.com <apogeusistemas(a)gmail.com> wrote: > > Hi: > > Can you tell me why when I run this script I only get this output ? > > solaris> cat script1 > > for file in `ls -R` > do > grep -iw alter $file > /apl/applprox/script1_output > grep -iw modify $file >> /apl/applprox/script1_output > grep -iw replace $file >> /apl/applprox/script1_output > done > > > > grep: can't open OEXWFOIB.pls > grep: can't open OEXWFOIB.pls > grep: can't open OEXWFOIS.pls > grep: can't open OEXWFOIS.pls > grep: can't open OEXWFOIS.pls > grep: can't open OEXXHDRB.pls > grep: can't open OEXXHDRB.pls > grep: can't open OEXXHDRB.pls > grep: can't open OEXXHDRS.pls > grep: can't open OEXXHDRS.pls > grep: can't open OEXXHDRS.pls > grep: can't open OEXXLINB.pls > grep: can't open OEXXLINB.pls Offhand, I'd say you can't open those files. Do you have read permission for them? -- Christopher Mattern NOTICE Thank you for noticing this new notice Your noticing it has been noted And will be reported to the authorities |