Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding all files with certain extension in Unix?

I have a file /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

I am trying to find if I have the *.jdk anywhere else on my hard drive. So I do a search command:

find . -name "*.jdk" 

But it doesn't find anything. Not even the one I know that I have. How come?

like image 679
Prostak Avatar asked Dec 22 '11 17:12

Prostak


People also ask

How do I search for all files with specific extensions?

For finding a specific file type, simply use the 'type:' command, followed by the file extension. For example, you can find . docx files by searching 'type: . docx'.

How do I find all files containing specific text in Unix?

Without a doubt, grep is the best command to search a file (or files) for a specific text. By default, it returns all the lines of a file that contain a certain string. This behavior can be changed with the -l option, which instructs grep to only return the file names that contain the specified text.


1 Answers

find . only looks in your current directory. If you have permissions to look for files in other directories (root access) then you can use the following to find your file -

find / -type f -name "*.jdk" 

If you are getting tons of permission denied messages then you can suppress that by doing

find / -type f -name "*.jdk" 2> /dev/null 
like image 197
jaypal singh Avatar answered Oct 22 '22 06:10

jaypal singh