Tell me more ×
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

3 Answers

up vote 9 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

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

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.