View Full Version : [all variants] [SOLVED] Find files (or directories) from terminal?
BassKozz
August 15th, 2008, 06:09 PM
What is the command to find files (or directories) from the terminal?
I've tried using the 'find' command, but that doesn't seem to drill down into subdirectories (or at least I am unfamiliar with the attribute required to do so).
TIA,
-BassKozz
drs305
August 15th, 2008, 06:14 PM
What is the command to find files (or directories) from the terminal?
I've tried using the 'find' command, but that doesn't seem to drill down into subdirectories (or at least I am unfamiliar with the attribute required to do so).
TIA,
-BassKozz
sudo find / -type f -iname filename
This will start at the root directory and search all folders/subfolders on the root partition. Since this will search /media and /mnt, if any partitions are mounted on these mount points they will be searched as well.
-type is either f for file or d for directory
-iname makes it case insensitive (e.g. Box or box will be found)
-maxdepth X will PREVENT the search from descending more than X levels
BassKozz
August 15th, 2008, 06:16 PM
sudo find / -type f -iname filename
Thanks drs305,
BTW do you live in Miami (305)?
p.s. to anyone looking: Find Man page (http://unixhelp.ed.ac.uk/CGI/man-cgi?find) use '-type d' to find directories.
I read the Man page prior to posting this thread, but it was a bit confusing, so thanks again for helping decipher drs305 ;)
drs305
August 15th, 2008, 06:25 PM
Thanks drs305,
BTW do you live in Miami (305)?
p.s. to anyone looking: Find Man page (http://unixhelp.ed.ac.uk/CGI/man-cgi?find) use '-type d' to find directories.
I read the Man page prior to posting this thread, but it was a bit confusing, so thanks again for helping decipher drs305 ;)
Nope, east coast but not fla. ;-)
rampageoberon
August 15th, 2008, 06:27 PM
I find the locate command very useful. The slocate database is automatically updated daily.
If you want to update the database then use the following command
sudo updatedb
To find the location of the file
locate <filename>
BassKozz
August 15th, 2008, 07:10 PM
Thanks rampageoberon,
Can 'locate' find directories too?
tahina
August 15th, 2008, 07:20 PM
You can also use tracker (the indexing- and searchtool with the orange magnifyingglass in the gnome panel) from the commandline, with the command tracker-search. (This is a bit overkill for finding files, though. It searches inside documents too.)
BassKozz
August 17th, 2008, 07:12 PM
I find the locate command very useful. The slocate database is automatically updated daily.
If you want to update the database then use the following command
sudo updatedb
To find the location of the file
locate <filename>
Thanks rampageoberon,
Can 'locate' find directories too?
:bump:
rampageoberon
August 18th, 2008, 07:03 PM
Yes it does find directories as well as files.
Powered by vBulletin® Version 4.2.2 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.