Re: xargs verses exec

  • From: "Radoulov, Dimitre" <cichomitiko@xxxxxxxxx>
  • To: Joel.Patterson@xxxxxxxxxxx
  • Date: Tue, 24 Jul 2012 21:33:22 +0200

Just to add that you're seeing the output of ls because ls with no 
arguments defaults to the current directory,
rm with no arguments is not a valid syntax and your command won't remove 
anything:

zsh-4.3.14[t]% find  -name x | xargs ls
infile
zsh-4.3.14[t]% find  -name x | xargs rm
rm: missing operand
Try `rm --help' for more information.


Regards
Dimitre


On 24/07/2012 21:24, Radoulov, Dimitre wrote:
> Hi Joel,
>
> On 24/07/2012 20:50, Joel.Patterson@xxxxxxxxxxx wrote:
>> It has come time to switch to xargs instead of exec.  I have found 
>> two issues with xargs, but I'll only ask one now.
>>
>> Say I change to ORACLE BASE and do a find on 'all the subdirectories' 
>> piping through xargs, but... there are no files that meet the 
>> criteria -- say the extension is ".abc".
>>
>> cd ${ORACLE_BASE}
>> find */cdump -name "*.abc" -type f -mtime +40 -print | xargs ls -ltr
>>
>> Then, the find command comes back with the contents of the 
>> ${ORACLE_BASE} directory.
>
> GNU xargs has the -r/--no-run-if-empty option for this :).
>
> That said, _most_ find implementations support the {} + syntax for 
> xargs emulation:
>
> [...[

--
//www.freelists.org/webpage/oracle-l


Other related posts: