small uniq trick

Giorgos Keramidas keramida at ceid.upatras.gr
Mon Jan 28 02:25:48 EET 2008


On 2008-01-28 01:18, Christos Ricudis <ricudis at itc.auth.gr> wrote:
> Otan exete ena pelwrio arxeio ths morfhs
> 
> a
> a
> a
> b
> c
> c
> c
> b
> b
> b
> a
> c
> b
> c
> a
> 
> 
> kai 8elete na kanete kati san
> 
> cat lala.koko | sort | uniq
> 
> sas symferei perissotero na kanete
> 
> cat lala.koko | uniq | sort | uniq
> 
> H prwth uniq 8a kopsei ta repetitions sto arxiko arxeio, elafrynontas 
> kata poly to baros ths sort prin to teliko uniq.
> 
> test runs (nai, giwrgo, einai epaneilhmmena runs) :
> 
> $ time cat datafile | cut -f2- -d: | uniq | sort | uniq > /dev/null
> 
> real    0m1.164s
> user    0m0.712s
> sys     0m0.429s
> 
> $ time cat worstcase | cut -f2- -d: |  sort | uniq > /dev/null
> 
> real    0m2.522s
> user    0m1.672s
> sys     0m0.782s

Metras poso xrono ekane h `cat' :(

Epishs mou th spaei otan xrhsimopoieitai h cat ekei pou arkei ena shell
redirection:

	uniq < worstcase | sort | uniq

/me paei pisw sth sphlia me ta shell scripts




More information about the Linux-greek-users mailing list