LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-08-2005, 07:00 PM   #1
LinuxSeeker
Member
 
Registered: Feb 2004
Location: Linuxland
Distribution: Ubuntu 5.10, KUbuntu 5.10, Mandrake 10.1 - Ubuntu 5.04 (Hoary)
Posts: 346

Rep: Reputation: 30
How to use "find"


Hello guys, I have read the manual but I haven't quite understood how it works. Can someone please give me an example such as what to do to find a file named "notes.txt" under the "/" directory by searching all the subfolders (and / as well)?
 
Old 06-08-2005, 07:02 PM   #2
juanbobo
Member
 
Registered: Mar 2005
Location: Chicago
Distribution: Gentoo AMD64
Posts: 365

Rep: Reputation: 30
find DIRECTORY -name FILENAME

If you want to find something within a file I think you can type...

grep -R STRING DIRECTORY
 
Old 06-09-2005, 03:21 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
To use your request as an example:

find / -name notes.txt 2>/dev/null

The first param ie '/' represents the dir to start from; find automatically recurses down through all sub-dirs from it's starting point, so don't use '/' unless you really are lost ...
the last bit ie '2>/dev/null' sends stderr (ie error msgs) to null, basically throws them away.
Very handy, particularly if you start from '/' as you'll get a lot of these, even as root user...
You can also change '-name' to '-iname' which means match filename case-insensitive.
If you want to use a wildcard eg *.txt, enclose in single quote marks to get the desired effect eg
find . -name '*.txt' 2>/dev/null

Use
man find
to read up on this cmd.
 
Old 06-09-2005, 07:18 AM   #4
heema
Senior Member
 
Registered: Sep 2003
Location: Egypt
Distribution: Arch
Posts: 1,528

Rep: Reputation: 47
find for Dummies
http://slackworld.berlios.de/02/classes.html
 
Old 06-10-2005, 10:50 AM   #5
securehack
Member
 
Registered: Sep 2003
Location: United States
Distribution: Slackware 10.1, Debian 3.0, WinXProSP1, Fedora Core 3
Posts: 425

Rep: Reputation: 30
Informative post heema. =)

--Abid Kazmi
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 08:42 AM
Several "find -exec" and "find | xargs" questions thanhvn Programming 4 12-02-2005 02:04 PM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 03:32 PM
Where can I find the "make" & "cc" packages?? sayeed_ather Mandriva 2 04-28-2004 03:02 AM
"host" ok, but "ping" can't find ip address hardigunawan Linux - Networking 2 05-16-2002 06:41 PM


All times are GMT -5. The time now is 02:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration