| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#11
|
| markg9-at-yahoo.com wrote: > I've been trying to search for a text sting in all files on the drive. > The following works , BUT the actual file name is not returned (only > the string occurence is printed). What else do I need??? > > find /opt/icor/fx -exec grep "text string" {} \; > > Thanks a llot, > Mark > I use often find it lists the file found first and then executes the grep which might find the pattern or not. you have then the filename listing group together with the output of grep below. an alternative may be '-ls' instead of '-print' -ls lists the file in long format as the 'ls' command does -print lists only the filename itself Sven -- Sven-Olaf Hilmer, Solaris System Engineer http://www.hilmer-informatik.ch |
|
#12
|
| In article <1181663967.935774.73180@z28g2000prd.googlegroups.c om>, Karoly VEGH >On Jun 12, 3:34 pm, mar...@yahoo.com wrote: >> I've been trying to search for a text sting in all files on the drive. >> The following works , BUT the actual file name is not returned (only >> the string occurence is printed). What else do I need??? >> >> find /opt/icor/fx -exec grep "text string" {} \; > >find path/to/wherever -type f | xargs grep lists > >this one doesnt even execute grep for every file found, and finds only >files. A bad advise..... better call: find path/to/wherever -type f -exec "text string" {} + -- EMail:joerg-at-schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin js-at-cs.tu-berlin.de (uni) schilling-at-fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily |
|
#13
|
| On 13 Jun 2007 20:01:47 GMT js-at-cs.tu-berlin.de (Joerg Schilling) wrote: > In article <1181663967.935774.73180@z28g2000prd.googlegroups.c om>, > Karoly VEGH >>On Jun 12, 3:34 pm, mar...@yahoo.com wrote: >>> I've been trying to search for a text sting in all files on the drive. >>> The following works , BUT the actual file name is not returned (only >>> the string occurence is printed). What else do I need??? >>> >>> find /opt/icor/fx -exec grep "text string" {} \; >> >>find path/to/wherever -type f | xargs grep lists >> >>this one doesnt even execute grep for every file found, and finds only >>files. > > A bad advise..... > > better call: > > find path/to/wherever -type f -exec "text string" {} + ^^^ grep Also not that great. If the last grouping is 1 file you won't get the filename for that result. 1. find -exec grep -l {} + 2. find -exec grep {} /dev/null + 3. grep -r (for GNU grep) -frank |
|
#14
|
| Joerg Schilling wrote: > In article <1181663967.935774.73180@z28g2000prd.googlegroups.c om>, > Karoly VEGH >> On Jun 12, 3:34 pm, mar...@yahoo.com wrote: >>> I've been trying to search for a text sting in all files on the drive. >>> The following works , BUT the actual file name is not returned (only >>> the string occurence is printed). What else do I need??? >>> >>> find /opt/icor/fx -exec grep "text string" {} \; >> find path/to/wherever -type f | xargs grep lists >> >> this one doesnt even execute grep for every file found, and finds only >> files. > > A bad advise..... > > better call: > > find path/to/wherever -type f -exec "text string" {} + Someone who can say when '+' become available in Solaris find ??? |
|
#15
|
| In article Thommy M. >Darren Dunham wrote: >> "Thommy M. Malmström" >>> markg9-at-yahoo.com wrote: >>>> I've been trying to search for a text sting in all files on the drive. >>>> The following works , BUT the actual file name is not returned (only >>>> the string occurence is printed). What else do I need??? >>>> >>>> find /opt/icor/fx -exec grep "text string" {} \; >>>> >> >>> Another approach maybe. It's faster too >> >>> find /opt/icor/fx >> >> It's no faster than the '+' version shown, and it will fail by default >> on filenames that have spaces or newlines in the name. > >Well, the '+' thing is a little new to me... It is more than 15 years old now...... -- EMail:joerg-at-schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin js-at-cs.tu-berlin.de (uni) schilling-at-fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily |
|
#16
|
| On Wed, 13 Jun 2007 06:14:52 +0200 Sven Hilmer > I use often > > find > > it lists the file found first > and then executes the grep which might find the pattern or not. > you have then the filename listing group together > with the output of grep below. It's been a while now that find has the + terminator in addition to the semi-colon: find It instructs find to submit as many file names as possible to a single instance of grep (which then conveniently supplies you with the file name in front of every match). -- Stefaan A Eeckels -- "Technically, Windows is an 'operating system,' which means that it supplies your computer with the basic commands that it needs to suddenly, with no warning whatsoever, stop operating." -Dave Barry |
|
#17
|
| On Wed, 13 Jun 2007 20:10:38 GMT "Thommy M." > > Someone who can say when '+' become available in Solaris find ??? It's already available on Solaris 2.6 (I checked it just now). Maybe even earlier, but I no longer have access to older versions of Solaris. -- Stefaan A Eeckels -- You know, it is almost always the case in the real world that something is "fair" when you like it and "unfair" when you don't. -- Jeffrey Siegal in gnu.misc.discuss |
|
#18
|
| In article <2bYbi.2121$ZA.1212@newsb.telia.net>, Thommy M. >> better call: >> >> find path/to/wherever -type f -exec "text string" {} + > >Someone who can say when '+' become available in Solaris find ??? It is part of SVr4 since the very beginning. -- EMail:joerg-at-schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin js-at-cs.tu-berlin.de (uni) schilling-at-fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily |
|
#19
|
| Hej Thommy! It was just missing from the man page. I filed bug 4382701 against the man page for Solaris 9 in Oct 2000. Thomas |
|
#20
|
| Stefaan A Eeckels >On Wed, 13 Jun 2007 20:10:38 GMT >"Thommy M." >> >> Someone who can say when '+' become available in Solaris find ??? >It's already available on Solaris 2.6 (I checked it just now). Maybe >even earlier, but I no longer have access to older versions of Solaris. The source code suggests it was already in 2.0. But it wasn't documented until much later. Casper -- Expressed in this posting are my opinions. They are in no way related to opinions held by my employer, Sun Microsystems. Statements on Sun products included here are not gospel and may be fiction rather than truth. |
![]() |
| Thread Tools | |
| Display Modes | |