How to sort a file based on field postion?
For eg. I need to sort the below given file. Based on 4th,5th and 8th positions. Please help. I tried the following command, i
You could try :
sort -d -t $'\n' -k 1.42,1.44 -k 1.47,1.57 -k 1.59,1.70 -k 1.73,1.82 input.txt>
You would get this :
010835 03 0000000010604CADB 1465045344 BINHH TZ QKZ 4604698441 010835 03 0000000010604CAQZ 0912104072 QNZAW AZ ATC 1704698441 010835 03 0000000010604CBEC 8737518498 DICDC CY HWT 0904698441 010835 03 0000000010604CERV 5648240160 FFVFV DZ UXE 8404698441 010835 03 0000000010604CIFN 2374902637 NOMJU VZ XHU 6704698441 010835 03 0000000010604COGM 3281553523 JSLKI YZ CLK 5804698441 010835 03 0000000010604CPCL 4190899186 PQJLL QZ UPL 3004698441 010835 03 0000000010604CTTV 2555338251 TTBGB FZ EZS 9504698441 010835 03 0000000010604CZWX 7823775785 WDXSD GZ DDF 2804698441
the idea is to use the $'\n' (newline) char is field separator so every line is 1 field
Inspiration from http://www.computing.net/answers/unix/sort-file-by-position-/7735.html