Linux – the command to find a jar file in a particular folder

findlinux

What is the command to find a jar file in a particular folder?

Say I want to find log4j.jar in the /dev directory, what command should I use?

Best Answer

You can use find. In your case:

find /dev/ -name log4j.jar

You can also use wildcards, for example

find /dev/ -name \*.jar

would find all .jar files under /dev.

Note that find does the search resursively, i.e. searches all subfolders of /dev, too. You can adjust the maximal depth of your search using the -maxdepth parameter, see man find for more details.

Note also that in your case you should perhaps have root permissions because not all subfolders in /dev are readable by all users. In a debian/ubuntu system you could just add a sudo before the find command.


If you don't want to search resursively you could just use ls for example

ls /dev/*jar

will list all jar files under /dev.

Related Question