awk, print all columns and add new column with substr -


i have table

usi,name,2d-3d ro0001,patate,2d ro0002,haricot,3d ro0003,banane,2d ro0004,pomme,2d ro0005,poire,2d 

and want

usi,name,2d-3d ro0001,patate,2d,ro_2d_patate ro0002,haricot,3d,ro_3d_haricot ro0003,banane,2d,ro_2d_banane ro0004,pomme,2d,ro_2d_pomme ro0005,poire,2d,ro_2d_poire 

i manage obtain construction "ro_2d_patate" awk

awk -f "," '{print substr($1,1,2)"_"substr($3,1,2)"_"$2}' test4.txt 

but want print column $0 before second table.

i tried still novice !!!!

any idea on there?

awk -f, '{print $0 (nr>1 ? fs substr($1,1,2)"_"$3"_"$2 : "")}' test4.txt 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -