Hi this may be a very newbie question, but why doesnt the xargs /bin/ls work in this case? I thought it was supposed to be faster? Also what are those /fd/3 directories?
sh-3.2# find / -name 'GOALS*' -exec ls -l {} \;
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
.... This returns me the expected result....
However this returns the whole list of files in the directory
sh-3.2# find / -name GOALS* -type f | xargs /bin/ls -l
I am on a MacOS.
Best Answer
you need to quote the
*
in the secondfind
command,the
/dev/fd/*
are devices which corresponds withstdin
,stdout
,stderr
etc. thouse devices are simlinked and are different for each process,the
-type f
says, the result has to be regular file, thus the/dev/fd/*
are not in the result as they are block devices,the
xargs ls -l
does the same as yourls -l {}
... I even doubt the better performance in this case, butxargs
is smarter and there are reasons to use it, eg. correct handling of files with whitespaces inside it,If you are debugging the second version of your
find
, first of all see the output w/o the| xargs ls -l
part