lunedì 24 giugno 2013

Sorting a file with pipe-delimited fields using unix sort

Hi All

Today a simple command to sort a file with pipe-delimited fields.

My file is :

EG|TW|SA|04/05/2009||
EG|NA|EN|02/05/2003||
SS|TW|SA|04/05/2009||
CD|DC|TI|30/12/2004||
ET|EG|TI|02/05/2003||
NI|SS|EN|18/02/2005||
EG|ET|TI|02/05/2003||
IN|ET|TI|21/09/2000||
SS|SS|SA|28/02/2005||
IN|PR|EN|01/11/2003||
PR|TW|SA|04/05/2009||
SS|EN|TN|18/02/2005||
EG|DC|TI|17/09/2010||
EG|EI|SA|04/08/2005||
NA|IN|SA|21/09/2000||

To sort all records by third field.
I can use these simple command :

sort -t"|" -k 3 [file_name]

Where -t is an option where u can explain field separator and with -k you can explain third field.

Stay tuned.





Nessun commento:

Posta un commento

Check Mid Year Objectives

Hi all Today middle year check of my 2026's goals. 1. ENGLISH Improve listening comprehension (So and So)   See at least one or two film...