The target is not to list temp/run*.* files. The target is to understand why the second command does not work.

First command:

find . \( -name 'temp' \) -print0 | xargs -0 -L 1 -I datafind ls -ltr datafind

list all the files inside temp folders from actual directory

Second command:

find . \( -name 'temp' \) -print0 | xargs -0 -L 1 -I datafind ls -ltr datafind/run*.*

gives cannot access error on every directory that worked with the previous command.

I searched and read man pages and examples but I can not find why the second command does not work. Any clue, please?

  • Not asked, but why not filter at find time? find . ! \( -name 'run*' \) -print
    – Hennes
    Oct 2, 2013 at 16:17
  • Because there are other 'run*' files on other folders, I do not want to see. Also, please, target is: understand why second command does not work.
    – jose
    Oct 2, 2013 at 16:21

1 Answer 1


The confusion is that wildcard characters such as * and *.* are evaluated by the shell when you type the command.

Therefore datafind/run*.* is evaluated by the shell and would be replaced by the filenames which match that, but it does not find any files that match. Therefore datafind/run*.* is given to the xargs command and then it passes that right through to the ls command.

The ls command does not understand wildcard characters so it just takes its input and tries to find a file with that name. There is no file with the name run*.* so you get an error No such file or directory.

  • Ohhh. Do you mean ls work is only print the data that shell has gathered? Never suspected but it matches with result :) Thank you very much.
    – jose
    Oct 2, 2013 at 16:39
  • 1
    find . ( -name 'temp' ) -print0 | xargs -0 -L 1 -I datafind sh -c "ls -ltr datafind/run*.*" Perfect. Many thanks again
    – jose
    Oct 2, 2013 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.