I want to list all PDF files in the directories of the current working directory. What command can do this?

I remember a combination of ls and */*.pdf but don't remember what exact combination.

  • Do you want a list of all pdf files or a list of all files which have the filenameextension ".pdf"? – Ocaso Protal Jan 31 '12 at 10:51

You can use:

find -iname '*.pdf'

with ls maybe:

ls -lR | grep '/\|pdf$'

  • Firs command does not work, output: ls: cannot access *.pdf: No such file or directory – ashim Jan 31 '12 at 4:21
  • 1
    ups, sorry. that command is indeed wrong. I'll edit – zetah Jan 31 '12 at 4:24
  • 1
    Always quote find patterns (as in -name '*.pdf'), to prevent the shell to expand the glob pattern (this would happen if you have some pdf file in the current directory). – enzotib Jan 31 '12 at 5:43
  • 2
    In case you happen to have files named with inconsistent character case, use -iname \*.pdf to also find files ending in .PDF, .PdF, etc. – Tom Regner Jan 31 '12 at 7:55

Use find

find . -name '.pdf'

See also: http://content.hccfl.edu/pollock/unix/findcmd.htm

  • Shouldn't this be find . -name '*.pdf'? – nispio Sep 4 '13 at 22:24
  • 1
    You do not need a wildcard with find – Panther Sep 5 '13 at 16:30
  • You do on Mac @Panther – khaverim Mar 5 '19 at 20:01
  • @khaverim what OS is Mac? – thymaro Sep 5 '19 at 13:49
  • On Ubuntu I also need find . -name '*.pdf' – Foton Oct 3 '19 at 15:59

The easiest way (if you are using Ubuntu Desktop):

Go to your home folder in Nautilus, press Ctrl+F and search for .pdf.

Screenshot showing search process

You can also change the location and you can make your search more specific.

@WarriorIng64 Note that this on its own will locate all files with .pdf occurring anywhere in the filename. If you specifically want files that the system identifies as PDFs, click the green + button next to "Reload", add the "File Type" "Pdf / Postscript" filter and click "Reload" to get only actual PDFs. enter image description here

  • 2
    @WarriorIng64 UPDATED – One Zero Jan 31 '12 at 10:24
  • Beautiful. Crazy I forgot how simple this was. – don.joey May 22 '14 at 9:26

Simplest way will be:

locate *.pdf

This command will find all the PDF files present in your system.

  • 2
    Watch out for shell globbing doing magic here for you. If the *.pdf expands to files in the current working directory, then these will be provided to the locate command, not the raw *.pdf argument. – gertvdijk Aug 19 '13 at 18:32

Use the command:

ls | grep .pdf

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.