Splitting the Data using awk

Hello All,

I have a comma delimiter file with 10 columns. I took the desired data but from $4 I need to split into two columns as 3+7 bytes.

awk -F"," -v OFS=',' '{print $2,$3,$4}' foo.txt
42366,11/10/2014,5012418769
42366,11/10/2014,2046955672
42366,11/10/2014,2076802951
42366,11/10/2014,501,2418769
42366,11/10/2014,204,6955672
42366,11/10/2014,207,6802951

Hi, have a look ar the substr() function.

1 Like

Thank you it worked.

awk -F"," -v OFS=',' '{print $2,$3,substr($4,1,3),substr($4,4,7)}' foo.txt

Good. Yes and if the last parameter is omitted in the second case, it will produce the remainder of the string.

substr($4,4)