In *nix, you can use the find command to find a file easily.

$find {directory-name} -name {filename}

1. Find a file in the root directory
If you have no idea where the file is located, you can search the entire system via the “/” root directory. Below example shows you how to find a file, named testing.txt in the entire system drive.

P.S To find in “/” root, you need permission, just issue sudo.

$ sudo find / -name 'testing.txt'
 
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/Users/mkyong/Documents/workspace/JavaTesting/testing.txt
/Users/mkyong/testing.txt

2. Find files in a specified directory
Find file testing.txt in directory /Users/mkyong and all its subdirectory..

$ sudo find /Users/mkyong -name 'testing.txt'
/Users/mkyong/Documents/workspace/JavaTesting/testing.txt
/Users/mkyong/testing.txt
Tags :
Founder of Mkyong.com, love Java and open source stuffs. Follow him on Twitter, or befriend him on Facebook or Google Plus.
Here are some of my recommended Books

Related Posts

Popular Posts