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?
Best Answer
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. Thereforedatafind/run*.*
is given to thexargs
command and then it passes that right through to thels
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 namerun*.*
so you get an error No such file or directory.