![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| find , grep | james94538 | UNIX for Dummies Questions & Answers | 3 | 3 Days Ago 06:03 PM |
| grep, find or awk? | netrom | UNIX for Dummies Questions & Answers | 4 | 04-09-2008 02:03 PM |
| grep and find | MEllis5 | UNIX for Dummies Questions & Answers | 1 | 04-07-2008 05:16 AM |
| find then grep | flame_eagle | Shell Programming and Scripting | 7 | 03-13-2008 07:19 AM |
| find and grep | sarwan | High Level Programming | 4 | 04-10-2006 04:05 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi,
I would like to know which files contain a certain string. If I use 'grep "string" *' only the working directory is being searched. I also want to search the subdirectories. When I use 'find . -type f -print |xargs grep "string" > dev/null' I get the message 'xargs: missing quote?'. What's up? Should I use another command? Thanks in advance. Anika |
| Forum Sponsor | ||
|
|
|
||||
|
Doing a find and then greping will certainly find the string within a string (in the file name) and works much better and faster. You are right PxT, this will not search the string within the file.
Code:
find / | grep lib /usr/lib/gdk-pixbuf/loaders/libpixbufloader-png.so.1.0.0 /usr/lib/gdk-pixbuf/loaders/libpixbufloader-pnm.a /usr/lib/gdk-pixbuf/loaders/libpixbufloader-pnm.la /usr/lib/gdk-pixbuf/loaders/libpixbufloader-pnm.so.1.0.0 /usr/lib/gdk-pixbuf/loaders/libpixbufloader-ras.a /usr/lib/gdk-pixbuf/loaders/libpixbufloader-ras.la /usr/lib/gdk-pixbuf/loaders/libpixbufloader-ras.so.1.0.0 /usr/lib/gdk-pixbuf/loaders/libpixbufloader-tiff.a /usr/lib/gdk-pixbuf/loaders/libpixbufloader-tiff.la /usr/lib/gdk-pixbuf/loaders/libpixbufloader-tiff.so.1.0.0 /usr/lib/gdk-pixbuf/loaders/libpixbufloader-xpm.a /usr/lib/gdk-pixbuf/loaders/libpixbufloader-xpm.la /usr/lib/gdk-pixbuf/loaders/libpixbufloader-xpm.so.1.0.0 /usr/lib/gdk-pixbuf/loaders/libpixbufloader-bmp.so /usr/lib/gdk-pixbuf/loaders/libpixbufloader-bmp.so.1 /usr/lib/gdk-pixbuf/loaders/libpixbufloader-gif.so /usr/lib/gdk-pixbuf/loaders/libpixbufloader-gif.so.1 Yes, it does not search the actual file. I normally use PERL for that and not xargs. For some strange reason, xargs and I don't gel.... when I have to search files and strings within lots of files I use command line PERL. [Edited by Neo on 01-31-2001 at 08:52 PM] |
|
|||
|
Quote:
grep -r "string" * works pretty well on Linux(RH). However this is not a comprehensive method. But I think this could be used for what poster is mentioned since he is using '*'(this cause grep read all files under each directory recursively). But if he uses grep -r "www" html* will only recurse into subdirectories whose names starts with "html". so if there is a subdirectory whose name is not starts with "html" will be ignored even if it has the file that contain "www" string. my grep version: GNU grep 2.3 |
|||
| Google The UNIX and Linux Forums |