Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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 wanted to see all files modified within the last 10 days and who owned them, so I entered the following to give me an idea how many results would be returned;

find . -maxdepth 1 -mtime -10

I then issued the command;

find . -maxdepth 1 -mtime -10 -exec ls -lh {} \;

Both commands give very different result, but I don't understand why. Can someone explain what is going on and why they produce different results?

share|improve this question
Either add -type f to list only files, or add -d to the ls command. Otherwise ls will list the directory contents again. – Dubu Jun 17 '14 at 13:05
up vote 4 down vote accepted

Because you don't use option -type f, find will return all folders and files. In second command, if a folder is found, command ls -lh will list its content, causing more result than first command.

$ find . -maxdepth 1 -mtime -10 | wc -l
$ find . -maxdepth 1 -mtime -10 -exec ls -lh {} \; | wc -l

You should use:

find . -maxdepth 1 -type f -mtime -10

find . -maxdepth 1 -type f -mtime -10 -exec ls -lh {} \;

to list files only.

share|improve this answer
what is 1 in end of second find? – Babyy Jun 17 '14 at 13:07
@Babyy: Sorry, mistyping. – cuonglm Jun 17 '14 at 13:08

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.