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

Re: find question (and xargs)

>Hi all,
>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?
Basically this is right, the {}'s get converted to the file name in
*find's argument list*. The arg list is ended at the |, because then
a new program is started.
Possible Solution:
use find's exec option:
find / -size +459976c -noleaf -type f -name '*.deb' -exec dpkg-split -s {} \
-exec rm {}
Be careful to quote the {{}'s appropriately, or the shell may munge them
into something different.
A more efficient solution would be to write a small perl program along the
sub dodir {
  my ($dir) = shift;
  opendir DIR, $dir;
  while (<readdir(DIR)>) {
    maybesplit if -f;
    dodir($_) if -d;
Cheerio, Jan
Jan Wender - wenderj@uni-trier.de - Universitaet Trier, Germany
Linux is the choice of a Gnu.
The man who letterspaces lowercase letters also steals sheep (F. Goudy)

Reply to: