How can this list be sorted by file size 'high to low'
Hello,
How can this list be sorted by file size 'high to low' Thanks Glenn Commands used so far: # rm index.html # wget -c http://download.kde.org/stable/appli...s/15.04.0/src/. # grep -i "\.xz" index.html | cut -d">" -f5,11 |cut -c10- | cut -d"<" -f1| sed 's/\">/ /' amor-15.04.0.tar.xz 171K analitza-15.04.0.tar.xz 223K ark-15.04.0.tar.xz 233K artikulate-15.04.0.tar.xz 3.7M audiocd-kio-15.04.0.tar.xz 51K blinken-15.04.0.tar.xz 553K bomber-15.04.0.tar.xz 384K bovo-15.04.0.tar.xz 103K cantor-15.04.0.tar.xz 348K cervisia-15.04.0.tar.xz 364K dolphin-plugins-15.04.0.tar.xz 57K dragon-15.04.0.tar.xz 390K ffmpegthumbs-15.04.0.tar.xz 20K filelight-15.04.0.tar.xz 281K granatier-15.04.0.tar.xz 1.3M gwenview-15.04.0.tar.xz 2.8M jovie-15.04.0.tar.xz 381K juk-15.04.0.tar.xz 433K kaccessible-15.04.0.tar.xz 20K kaccounts-integration-15.04.0.tar.xz 53K kaccounts-providers-15.04.0.tar.xz 12K kajongg-15.04.0.tar.xz 2.4M kalgebra-15.04.0.tar.xz 263K kalzium-15.04.0.tar.xz 3.8M kamera-15.04.0.tar.xz 35K kanagram-15.04.0.tar.xz 4.6M kapman-15.04.0.tar.xz 1.7M kapptemplate-15.04.0.tar.xz 689K kate-15.04.0.tar.xz 1.6M katomic-15.04.0.tar.xz 646K kblackbox-15.04.0.tar.xz 254K kblocks-15.04.0.tar.xz 1.2M kbounce-15.04.0.tar.xz 1.5M kbreakout-15.04.0.tar.xz 1.3M kbruch-15.04.0.tar.xz 883K kcachegrind-15.04.0.tar.xz 231K kcalc-15.04.0.tar.xz 81K kcharselect-15.04.0.tar.xz 83K kcolorchooser-15.04.0.tar.xz 4.2K kcron-15.04.0.tar.xz 170K kde-base-artwork-15.04.0.tar.xz 7.1M kde-baseapps-15.04.0.tar.xz 2.5M kde-dev-scripts-15.04.0.tar.xz 299K kde-dev-utils-15.04.0.tar.xz 50K kde-runtime-15.04.0.tar.xz 7.5M kde-wallpapers-15.04.0.tar.xz 86M kde-workspace-4.11.18.tar.xz 13M kdeartwork-15.04.0.tar.xz 134M kdeedu-data-15.04.0.tar.xz 94K kdegraphics-mobipocket-15.04.0.tar.xz 14K kdegraphics-strigi-analyzer-15.04.0.tar.xz 39K kdegraphics-thumbnailers-15.04.0.tar.xz 41K kdelibs-4.14.7.tar.xz 11M kdenetwork-filesharing-15.04.0.tar.xz 27K kdenetwork-strigi-analyzers-15.04.0.tar.xz 14K kdenlive-15.04.0.tar.xz 3.0M kdepim-4.14.7.tar.xz 14M kdepim-runtime-4.14.7.tar.xz 1.1M kdepimlibs-4.14.7.tar.xz 2.7M kdesdk-kioslaves-15.04.0.tar.xz 353K kdesdk-strigi-analyzers-15.04.0.tar.xz 18K kdesdk-thumbnailers-15.04.0.tar.xz 11K kdewebdev-15.04.0.tar.xz 2.4M kdf-15.04.0.tar.xz 146K kdiamond-15.04.0.tar.xz 4.0M kfloppy-15.04.0.tar.xz 52K kfourinline-15.04.0.tar.xz 275K kgamma-15.04.0.tar.xz 22K kgeography-15.04.0.tar.xz 6.4M kget-15.04.0.tar.xz 1.0M kgoldrunner-15.04.0.tar.xz 2.0M kgpg-15.04.0.tar.xz 791K khangman-15.04.0.tar.xz 3.7M kig-15.04.0.tar.xz 1.4M kigo-15.04.0.tar.xz 1.4M killbots-15.04.0.tar.xz 941K kiriki-15.04.0.tar.xz 115K kiten-15.04.0.tar.xz 11M kjumpingcube-15.04.0.tar.xz 162K klettres-15.04.0.tar.xz 2.7M klickety-15.04.0.tar.xz 766K klines-15.04.0.tar.xz 928K kmag-15.04.0.tar.xz 85K kmahjongg-15.04.0.tar.xz 1.0M kmines-15.04.0.tar.xz 610K kmix-15.04.0.tar.xz 379K kmousetool-15.04.0.tar.xz 35K kmouth-15.04.0.tar.xz 301K kmplot-15.04.0.tar.xz 647K knavalbattle-15.04.0.tar.xz 835K knetwalk-15.04.0.tar.xz 764K kolf-15.04.0.tar.xz 751K kollision-15.04.0.tar.xz 203K kolourpaint-15.04.0.tar.xz 1.1M kompare-15.04.0.tar.xz 336K konquest-15.04.0.tar.xz 396K konsole-15.04.0.tar.xz 451K kopete-15.04.0.tar.xz 6.0M kpat-15.04.0.tar.xz 2.9M kppp-15.04.0.tar.xz 684K kqtquickcharts-15.04.0.tar.xz 20K krdc-15.04.0.tar.xz 390K kremotecontrol-15.04.0.tar.xz 1.0M kreversi-15.04.0.tar.xz 464K krfb-15.04.0.tar.xz 319K kruler-15.04.0.tar.xz 126K ksaneplugin-15.04.0.tar.xz 13K kscd-15.04.0.tar.xz 91K kshisen-15.04.0.tar.xz 133K ksirk-15.04.0.tar.xz 4.8M ksnakeduel-15.04.0.tar.xz 291K ksnapshot-15.04.0.tar.xz 252K kspaceduel-15.04.0.tar.xz 248K ksquares-15.04.0.tar.xz 79K kstars-15.04.0.tar.xz 12M ksudoku-15.04.0.tar.xz 1.3M ksystemlog-15.04.0.tar.xz 373K kteatime-15.04.0.tar.xz 102K ktimer-15.04.0.tar.xz 144K ktouch-15.04.0.tar.xz 2.3M ktp-accounts-kcm-15.04.0.tar.xz 86K ktp-approver-15.04.0.tar.xz 20K ktp-auth-handler-15.04.0.tar.xz 26K ktp-common-internals-15.04.0.tar.xz 306K ktp-contact-list-15.04.0.tar.xz 48K ktp-contact-runner-15.04.0.tar.xz 16K ktp-desktop-applets-15.04.0.tar.xz 25K ktp-filetransfer-handler-15.04.0.tar.xz 22K ktp-kded-module-15.04.0.tar.xz 38K ktp-send-file-15.04.0.tar.xz 14K ktp-text-ui-15.04.0.tar.xz 283K ktuberling-15.04.0.tar.xz 4.1M kturtle-15.04.0.tar.xz 189K ktux-15.04.0.tar.xz 106K kubrick-15.04.0.tar.xz 105K kuser-15.04.0.tar.xz 132K kwalletmanager-15.04.0.tar.xz 446K kwordquiz-15.04.0.tar.xz 1.1M libkcddb-15.04.0.tar.xz 155K libkcompactdisc-15.04.0.tar.xz 74K libkdcraw-15.04.0.tar.xz 100K libkdeedu-15.04.0.tar.xz 128K libkdegames-15.04.0.tar.xz 5.5M libkeduvocdocument-15.04.0.tar.xz 97K libkexiv2-15.04.0.tar.xz 134K libkface-15.04.0.tar.xz 8.6M libkgeomap-15.04.0.tar.xz 121K libkipi-15.04.0.tar.xz 93K libkmahjongg-15.04.0.tar.xz 1.6M libkomparediff2-15.04.0.tar.xz 55K libksane-15.04.0.tar.xz 79K lokalize-15.04.0.tar.xz 930K lskat-15.04.0.tar.xz 908K marble-15.04.0.tar.xz 22M mplayerthumbs-15.04.0.tar.xz 27K okteta-15.04.0.tar.xz 491K okular-15.04.0.tar.xz 1.5M oxygen-icons-15.04.0.tar.xz 219M pairs-15.04.0.tar.xz 2.7M palapeli-15.04.0.tar.xz 1.7M parley-15.04.0.tar.xz 4.5M picmi-15.04.0.tar.xz 714K poxml-15.04.0.tar.xz 31K print-manager-15.04.0.tar.xz 91K rocs-15.04.0.tar.xz 521K signon-kwallet-extension-15.04.0.tar.xz 10K step-15.04.0.tar.xz 377K superkaramba-15.04.0.tar.xz 373K svgpart-15.04.0.tar.xz 8.8K sweeper-15.04.0.tar.xz 80K umbrello-15.04.0.tar.xz 1.5M zeroconf-ioslave-15.04.0.tar.xz 25K |
gnu sort is usually used for sorting. It handles "human readable" numbers as well as strict numerics - see the manpage.
|
Hi Glen,
For files greater that 1 Mega : Code:
grep -i "\.xz" index.html | cut -d">" -f5,11 |cut -c10- | cut -d"<" -f1| sed 's/\">/ /' | grep M | awk '{print $2" "$1}' | sort -rn Code:
grep -i "\.xz" index.html | cut -d">" -f5,11 |cut -c10- | cut -d"<" -f1| sed 's/\">/ /' | grep K | awk '{print $2" "$1}' | sort -rn |
Try "sort -h -r -k 2".
From the manpage on sort: Code:
-h, --human-numeric-sort |
If you are willing to settle for a computer-muggle approach, you can do it with a spreadsheet. I used Libre Office Calc and Emacs.
1. Put your file list into a text file (suggest a file name like FILENAME.txt). 2. Edit the file (I used Emacs) to put a space before each K and M (space will be a delimiter in the spreadsheet). 3. Open the text file with Libre Office Calc (the spreadsheet), choosing space as the delimiter. This will place the file length into two columns after the file name. 4. Mark the entire column containing the M and K. 5. Do a global find/replace, changing "M" to "=2^20" in the marked column. 6. Do a global find/replace, changing "K" to "=2^10" in the marked column. This will convert M and K to numbers. 7. In a fourth column, multiply the two previous columns to get the file size in bytes. 8. Do a descending sort on the entire spreadsheet using the newly computed column with the file length in bytes. Here is what I got (after reconstructing the sorted list with Emacs): Code:
oxygen-icons-15.04.0.tar.xz 229638144 |
Using sort is much simpler. Only one step.
|
awk -F'<[^<>]*>' '/\.xz/ { print $11 " " $6 } ' index.html | sort -h -r
|
Hello,
Here's what I did. I'll show them to you as a series of commands, so you can follow along. Basically, the idea is to gather two sets of input: one for file names and another for file sizes. Then, we can combine them together and do our operations on them. You can also do this in one single step - but I find this more easier to follow and work with :-) Code:
$> wget -c http://download.kde.org/stable/applications/15.04.0/src/ Have fun! |
Quote:
|
Quote:
:) |
All times are GMT -5. The time now is 11:04 AM. |