-2

The find command doesn't seem to search recursively when using the * wild card

I have a directory with several sub-directories inside it, many of which contain pdf's. There are no actual pdf's in the main directory, just in the sub-directories within it. I want to find all the pdf's without having to open all the directories.

find *.pdf

Shouldn't my code return all the pdfs in the sub-directories? I get 'No match'. Am I using the wild card correctly? I've also tried it like

*pdf

*.pdf*

*'.pdf'*

with no luck. Same results with ls. What am I not understanding?

whatIsLife
  • 31
  • 3

1 Answers1

0

please try with

find . -type f -name '*.pdf'

you can place your path instead of .

find /path/to/working/dir  -type f -name '*.pdf'
Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72
  • 1
    This will still fail if you have any files in the current directory which match the wildcard. You can fix this by adding quotes: `find . -type f -name '*.pdf'` – tripleee Jan 24 '19 at 10:45
  • thank you, I will keep this in mind for the next time. I am fixing my answer – Derviş Kayımbaşıoğlu Jan 24 '19 at 10:48
  • 3
    I notice you have answered many questions which ended up being closed as duplicates. Perhaps you want to try searching for a duplicate before spending time on composing a reply. The [Stack Overflow `bash` tag info page](/tags/bash/info) has a long list of common FAQs for Unix shell scripting. – tripleee Jan 24 '19 at 10:51