Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 10763  / 1 Year ago, tue, january 24, 2023, 9:00:26

Files & Folders Lens can be used to locate user's documents easily, but it seems ignoring system files and folders.



How can I search & locate system files and folders?



(Say for example I want to locate a folder named .metadata, which contains some settings of my Eclipse IDE, and I know that this folder is there in the file system somewhere but I don't know where)



I use 12.04 LTS


More From » 12.04

 Answers
7

You can use the find command to find folders with the -type d parameter. Here are a few examples:



#Search Root ( / ) folder for a folder called www

nits@excalibur:~$ sudo find / -name www -type d
/media/6E5E0E255E0DE6A5/cygwin/srv/www
/media/6E5E0E255E0DE6A5/cygwin/usr/share/doc/ImageMagick-6.4.0.6/www
/media/6E5E0E255E0DE6A5/cygwin/usr/share/doc/GraphicsMagick/www
/media/6E5E0E255E0DE6A5/cygwin/var/www
/media/6E5E0E255E0DE6A5/wamp/www

#Search current folder for a folder which start either Capital/lower-case M

nits@excalibur:~$ find . -iname m* -type d
./.local/share/telepathy/mission-control
./.config/menus
./.mozilla/firefox/vwfuj46p.default/minidumps
./.cache/indicators/messages
./.cache/chromium/Default/Media Cache
./Music
./.macromedia/Flash_Player/macromedia.com
./.jedit/macros
./.jedit/modes
./.gconf/apps/metacity


In the above examples, you would have noticed that only the directories with no subdirectories in them are listed. You can use mindepth/maxdepth to set the depth of the level that needs to be traversed.



#Search current directory for directories starting with either capital/lower-case M but only are present in the current directory

nits@excalibur:~$ find . -maxdepth 1 -iname m* -type d
./Music

# Traverse two levels (current level and one level under) in the current directory for directories starting with either capital/lower-case M:

nits@excalibur:~$ find . -maxdepth 2 -iname m* -type d
./.config/menus
./Music
./.jedit/macros
./.jedit/modes


There are a whole load of different options to search directories and files as well using find, you can look through the man-page accessible by man find for all the options and how to use it. Also although find is slower than locate it doesn't require updatedb to update a DB to search through because the search is performed real-time.


[#36978] Thursday, January 26, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
njuash

Total Points: 402
Total Questions: 125
Total Answers: 98

Location: Jersey
Member since Sun, Dec 4, 2022
1 Year ago
;