You are not logged in.

#1 2008-11-15 17:34:34

elflord
Member
From: France
Registered: 2008-11-09
Posts: 51

how to sort this text file ?

hi all

i have a text file that contains archlinux package information int he following formate:

File:alpine-2.00-1-i686.pkg.tar.gz     3623 KB     09/05/2008     10:53:00 PM
File:alsa-lib-1.0.18-1-i686.pkg.tar.gz     474 KB     11/08/2008     04:46:00 PM
File:alsa-oss-1.0.17-1-i686.pkg.tar.gz     50 KB     09/28/2008     04:25:00 PM
File:alsa-utils-1.0.18-1-i686.pkg.tar.gz     1047 KB     11/08/2008     04:46:00 PM

...

what is the easiest way to sort the order according to different criteria such as file size, creation time, name etc

i'm thinking of using a database software such as sqlite.
if this is the correct direction to go, can anyone show me some hints on how i should go about to accomplish this task ?

thanks in advance

Offline

#2 2008-11-15 17:55:32

elflord
Member
From: France
Registered: 2008-11-09
Posts: 51

Re: how to sort this text file ?

after some digging
it seems awk can do the trick
i found some code snippets
i'll try it later

but i'm still curious about doing this using sqlite and the SQL language
like can i create a database from a formated text file? etc
so anyone has some comments on this, you are still welcome

Last edited by elflord (2008-11-15 17:56:18)

Offline

#3 2008-11-15 19:17:36

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: how to sort this text file ?

just use sort:
sort by first field: sort -k 1,1 <file>
surt by first & second, second numeric: sort -k 1,2n <file>


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

Board footer

Powered by FluxBB