[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: find question (and xargs)

Erick Branderhorst writes ("find question (and xargs)"):
> this might be a more unix oriented question but I'll ask it anyway 
> because it is very debian related too:
> I would like to find packages bigger than 459976 bytes and split them
> with dpkg-split, if splitting is succesfull I'll remove the package.
> I have come at the following but it doesn't work (and can't figger 
> out why not from the manpages).
> find / -size +459976c -noleaf -type f -name '*.deb'|\
> xargs -n 1 dpkg-split -s {} && rm {}
> I was thinking that {} would be replaced by the filename but that's
> not the case. Anyone know how to solve this?

Your problem is that your command
 find / -size +459976c -noleaf -type f -name '*.deb'| xargs -n 1 dpkg-split -s {} && rm {}
is being broken up by the shell into
 find / -size +459976c -noleaf -type f -name '*.deb'| xargs -n 1 dpkg-split -s {} \
 && \
 rm {} \
so that the it runs dpkg-split on each file, file, but then if the
pipe succeeds (which in fact means just whether xargs exits with 0) it
just tries to remove `{}'.

You may need to invoke the shell explicitly to get the && behaviour,
  find .... | xargs -n 1 sh -c 'dpkg-split -s {} && rm {}'


Reply to: