Re: Package of non-development scripts?
On Tue, Jul 17, 2001 at 05:39:37AM -0400, Matt Zimmerman wrote:
> Is anyone currently maintaining a package of Debian-specific scripts that are
> not packaging-related (i.e., not devscripts)? Quite a few useful tidbits pass
> through this list, and it would be nice to collect all of those small scripts
> into one package. If nobody is collecting these, I'll likely start doing it,
> and package the result.
Please don't spoil the fun of reinventing tools. :-)
> Here's one that I use from time to time to see which packages are taking up the
> most disk space on my system. It's quite fast, thanks to grep-dctrl and perl,
> but doesn't fit in any package that I could find.
>
> == dpkg-pigs ==
> #!/bin/sh
>
> grep-status -nsInstalled-size,Package -F Status ' installed' \
> | perl -p00l12 -e 's/\n/ /' \
> | sort -rn
All perl (faster) one-liner (pythonistas enjoy/shudder):
perl -00 -e 'map {printf"%-24s%10d\n",@$_}(sort{$a->[1]<=>$b->[1]}grep{@$_}
map{%s=(/^(\S{3})\S+:\s+(.+)$/mg);($s{Sta}=~/ i\S+d$/)?($t+=$s{Ins},
[$s{Pac},$s{Ins}]):0;}<>),["total",$t]' /var/lib/dpkg/status
Or in the form of a slightly more readable script:
#!/usr/bin/perl -w
$/ = "";
open S, "</var/lib/dpkg/status";
map { printf "%-24s%10d\n", @$_} (
sort { $a->[1] <=> $b->[1] }
grep { @$_ }
map { %s = (/^(\S{3})\S+:\s+(.+)$/mg);
($s{Sta} =~ / i\S+d$/) ? ( $t += $s{Ins}, [$s{Pac},$s{Ins}]) : 0
} <S>
), ["total",$t];
close S;
It can be also done in awk, I guess, but the sorting would be a bit harder
(I have actually seen awk scripts implementing their own bubblesort, some
people just really hate perl).
Any sed bigots in the audience? ;-)
Cheers,
Joost
Reply to: