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 have the find command as follows:

find /jobs/logs/* -prune -name '*.log' -type f -mtime +1 |
    while read LOGFILE
        echo $LOGFILE

This is failing due to the following error:

/usr/bin/find: arg list too long

Can anyone suggest a way to fix this?

(This is a continuation of my previous question.)

share|improve this question

Try changing your find command to:

find /jobs/logs/. ! -name . -prune -name *.log -type f -mtime +1 

This tells find to exclude the . directory and prune all the rest, so that it doesn't descend further.

Take a look at this page for more information: Limit the search to the current directory portably

share|improve this answer

Let find to the directory traversal, that's its job! Building on my previous answer:

find /jobs/logs/. -name . -o -type d -prune -o
                  -type f -mtime +1 -exec sh -c 'echo "$0"' {} \;

Incidentally, note that I used -exec to make find invoke a command — that's what it's for.

Also, note that read LOGFILE does not read a line of input: it strips leading whitespace and interprets backslashes. A reliable way to read a line is IFS= read -r LOGFILE.

share|improve this answer

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.