Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wrote the script below to find the number of PDF files in a given directory. However, it instead shows all the files in the directory:


ls -al $message $message1 

What's wrong with the script?

share|improve this question
Since you appear to be using bash, I'll refer you to this method of counting the number of files in a directory. Any approach that uses ls is very likely to be non-portable and incorrect, so I'd advise against going down that road. – jw013 Dec 21 '11 at 8:14

Because this is what the ls command should do. Your script effectively runs

ls -al . *.pdf

And that will list all the files in current directory (as specified by .). Leave out the dot and you'll have just the PDFs.

share|improve this answer
Thanks a lot rozcietrzewiacz – user13522 Dec 21 '11 at 18:09

Your Answer


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.