is there a way to list all packages by size?
pkgtool just lists it in alphabetical order.
Thanks |
ls -alS /var/log/packages | more
would be one way of listing all the packages that you have installed, one page at a time. samac |
That doesnt work properly. I was looking for something that would sort according the the installed size or as slackware mentions "uncompressed package size".
|
Code:
grep UNCOMPRESSED /var/log/packages/* | awk -F: '{print $3,$1}' | sort -rn |
Make that sort -rh to sort in 'human-readable' form.
|
The sizes are already in KiB, so -h is superfluous.
|
Quote:
|
fordfas
|
Quote:
Code:
awk -F: '/UNCOMPRESSED/ {print $2,FILENAME}' /var/log/packages/* | LC_ALL=C sort -rh | less |
My results suggest the first form is more efficient:
Code:
time grep UNCOMPRESSED /var/log/packages/* | awk -F: '{print $3,$1}' | sort -rh Quote:
Code:
time awk -F: '/UNCOMPRESSED/ {print $2,FILENAME}' /var/log/packages/* | LC_ALL=C sort -rh Quote:
|
sort -rh, thats what I was looking for, never knew the command awk existed lol. I have a lot to learn. Thanks for all our help.
|
Very Nice !
I turned the one-liner into a shell script with some options Not sure how to or if I can attach a shell script so here's the code: Code:
#!/bin/sh Code:
chmod 755 $HOME/bin/get-pkgsize -- kjh |
@allend: yep, I'm getting similar results. It appears that grep's regexp engine is faster than gawk's. Perhaps because the later supports backtracking? Although this article suggests that GNU awk uses the same approach as grep. Maybe gawk is slower in general...
|
fgrep UNCOMPRESSED /var/log/packages/* .... should be even faster
|
Interesting ...
I wonder why the complex get-pkgsize script is faster than the simple awk one-liner ? -- kjh Code:
[konrad@kjhlt5 ~]$ time fgrep UNCOMPRESSED /var/log/packages/* | awk -F: '{print $3,$1}' | LC_ALL=C sort -rh > /dev/null |
because awk is not built for speed; it's in fact quite slow, but does support alot of otherwise useful features. :-) nice script!
|
Thanks Ramurd.
What I found baffling was that I expected the get-pkgsize script to take longer than the simple awk one-liner because get-pkgsize is a gawk script in a shell-wrapper with which pipes output to sort then to another gawk script. Anyhow ... -- kjh(<G> it's not like the real delta-t's are significant in any case <G>) |
p.s. I use gawk every day for some serious data conversions( GB's of Data )
and I have found that the speed is close enough to perl's speed that I choose gawk over perl because I can use code-generators I've developed over the past 30-years :) |
Nice (g)awk kjhambrick.
Good to see someone use awk for something other than '{ print $1 }' for a change. |
Thanks mRgOBLIN !
I really do like gawk's syntax. It's quite capable of any text processing that I have ever thrown at it. I did figure out why get-pkgsize was so much faster than audriusk's original awk one-liner ... The get-pkgsize script invokes nextfile as soon as it finds the /^UNCOMPRESSED/ pattern in the stream OTOH, the awk one-liner scans the rest of each the files in /var/log/packages, looking for more instances of the pattern in each line. These are the times again. Note that the new one-liner with nextfile is about as fast as the grep pipeline. -- kjh p.s. not that the times of 0.02 secs vs 0.14 secs mean anything in the real world where the one-liner will be invoked :) Code:
# gnashley's fgrep suggestion: |
Quote:
Thankyou for the insightful investigation and explanation. Quote:
|
Quote:
Code:
rpm -qa --queryformat="%{size} %{name}-%{version}-%{release}\n" | sort -rn |
Quote:
|
And I wouldn't have had all the fun I had writing get-pkgsize :)
|
All times are GMT -5. The time now is 08:34 PM. |