linux - How to write awk command to group line data and dump to file -


one data file consists of multiple line data. quick of data file like:

./gc_string/datadata.distr  10  1273377106  2 ./gc_string/datadata.distr  10  -540812264  2 ./gc_string/datadata.distr  10  318171673  2 ./app_fib/datadata.distr  4  -1593911137  3 ./app_fib/datadata.distr  4  -1345649758  3 ./app_fib/datadata.distr  5  -1545930833  3 ./app_fib/datadata.distr  5  1916879527  3 ./app_fib/datadata.distr  5  609112984  3 ./app_fib/datadata.distr  6  111417553  3 ./app_fib/datadata.distr  6  -1545460791  3 ......... 

what want group line datas , write them each different files according 1st column. rule columns except 1st column written same file if 1st have same value. file name based on 1st column value. example, 2 files generated above data:

gc_string.txt ------------------- 10  1273377106  2 10  -540812264  2 10  318171673  2  app_fib.txt ------------------- 4  -1593911137  3 4  -1345649758  3 5  -1545930833  3 5  1916879527  3 .. 

i think bash awk can perform task. tried several ways fail. give me tips?

awk '{split($1,a,"/"); print $2,$3,$4 > a[2] ".txt"}' datafile 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -