FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 09-17-2010, 06:17 PM
Axel Freyn
 
Default searching inside files with find, cat and grep as a oneliner ...

Hi Albrecht,
On Fri, Sep 17, 2010 at 06:08:18PM +0000, Albretch Mueller wrote:
> search for files using a pattern (say all files with a certain extension)
> then search inside each of the found files for a word or regexp pattern
> You could do this using find, cat and grep in a script, but I was
> wondering about how could you do it with a oneliner

You could do it with a line like
find / -name filename -exec grep word {} ;

this will search for all files with the name "filename" and then use
"grep" in order to search for the expression "word" in this file.
The line outputs the grep-results.
You could also just output the filenames by using
find / -name filename -exec grep -l word {} ;

For more details, see "man find" and "man grep" ,-)

Axel


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20100917181702.GG17011@axel">http://lists.debian.org/20100917181702.GG17011@axel
 

Thread Tools




All times are GMT. The time now is 12:23 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org