Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find a file/directory that could be anywhere on linux command line? [closed]

Ideally, I would be able to use a program like

find [file or directory name] 

to report the paths with matching filenames/directories. Unfortunately this seems to only check the current directory, not the entire folder.

I've also tried locate and which, but none find the file, even though I know its on the computer somewhere.

like image 542
johncorser Avatar asked Jul 09 '14 13:07

johncorser


People also ask

How do you find a hidden file in a directory Linux?

First, browse to the directory you want to view. 2. Then, press Ctrl+h . If Ctrl+h doesn't work, click the View menu, then check the box to Show hidden files.


1 Answers

"Unfortunately this seems to only check the current directory, not the entire folder". Presumably you mean it doesn't look in subdirectories. To fix this, use find -name "filename"

If the file in question is not in the current working directory, you can search your entire machine via

find / -name "filename" 

This also works with stuff like find / -name "*.pdf", etc. Sometimes I like to pipe that into a grep statement as well (since, on my machine at least, it highlights the results), so I end up with something like

find / -name "*star*wars*" | grep star 

Doing this or a similar method just helps me instantly find the filename and recognize if it is in fact the file I am looking for.

like image 177
Russell Uhl Avatar answered Nov 07 '22 19:11

Russell Uhl