Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (18.4k points)
Ideally, I would be able to use the program like

a find [file or directory name]

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

I have tried to locate and which, but none found my file, even though I know it's on my computer somewhere.

1 Answer

0 votes
by (36.8k points)

"Unfortunately this seems to only check my 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 this current working directory, you can search your entire machine via

find / -name "filename"

This also works with the stuff like find / -name "*.pdf", etc. Sometimes I like to pipe that into the 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 this filename and recognize if it is the file I am looking for.

Want to be a Linux expert? Come and join this linux course

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...