find a file

jack jdangler at terremark.com
Mon Aug 6 12:49:16 UTC 2007


On Mon, 2007-08-06 at 08:44 -0400, Nils Kassube wrote:
> John Dangler wrote:
> > find -name "searchterm" /
> > Will search the entire drive for files...
> 
> Make that
> 
> find / -name "searchterm"

> because the path needs to precede other options.
Oops - Right again, Nils.  I typed that from my Blackberry in the car
this morning on my way to work...

> > As to the secondary question regarding grep, to find a specific word
> in
> > a file (or files) in a directory, I usually do this little shell
> > script, typed at the commandline- for word in `ls`
> > do
> > cat $word | grep "searchword"
> > done
> >
> > That will search each file in a directory and tell you which files
> have
> > the word you want (if any)
> 
> You can use grep alone:
> 
> grep -re "searchword" *
> 
> or if you only want to list the filenames:
> 
> grep -lre "searchword" *
> 
> 
> Nils
Very nice.  I need to do a bit of reading up on grep!  I've been typing
short shell scripts for years to do stuff like this...

> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
> 
> 
-- 
Jack Dangler
Secure Services Engineer II
Terremark Worldwide
786 871 2352 (Office)
786 219 9865 (Mobile)
www.terremark.com





More information about the ubuntu-users mailing list