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?


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.

  • Already used this command but not working – Cindrella Aug 8 '12 at 9:33
  • 7
    @Mohini: "not working" is not very descriptive, we can't guess how it is failing for you. Also, having a .jar file in /dev would be very, very non-conventional. If the above commands don't return anything, it means the file is not there. – Mat Aug 8 '12 at 9:36
  • You could try it searching a file you know it is in /dev – student Aug 8 '12 at 9:38
  • i have already downloaded those files from the path and used find command but still find command is not showing the path. – Cindrella Aug 8 '12 at 9:45
  • 2
    Is the file really in /dev or ~/dev? In other words, is the file somewhere under your home directory? Using find to search the wrong directory won't return what you expect. – ephsmith Aug 8 '12 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.