Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
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

4 Answers 4

up vote 10 down vote accepted

You can use:

find -iname '*.pdf'

with ls maybe:

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

share|improve this answer
    
Firs command does not work, output: ls: cannot access *.pdf: No such file or directory –  capoluca Jan 31 '12 at 4:21
    
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
    
ok, thanks. edited yet again... –  zetah Jan 31 '12 at 6:23
1  
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

share|improve this answer
    
Shouldn't this be find . -name '*.pdf'? –  nispio Sep 4 '13 at 22:24
    
You do not need a wildcard with find –  bodhi.zazen Sep 5 '13 at 16:30

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

share|improve this answer
1  
@WarriorIng64 UPDATED –  One Zero Jan 31 '12 at 10:24
    
Beautiful. Crazy I forgot how simple this was. –  don.joey May 22 at 9:26

Simplest way will be:

locate *.pdf

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

share|improve this answer
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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