read one line file and separate into multiple lines

I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field.

example input line:

192.168.1.145;44535;software20.org;80;yes;ThuDec113;50;50.8384422011;ThuDec113;50;57.2764792011;0;00;06.438037;58;29;29;28;29;1;25;526;36045;0;0;0;0;1/1;1/1;0;0;0;0;82;5599;346.4;1.6;192.168.1.145;44536;software20.org;80;yes;ThuDec113;50;51.5587192011;ThuDec113;51;10.7557082011;0;00;19.196988;224;97;127;96;127;7;124;3963;173749;3;0;3;0;1/4;1/1;0;0;0;0;206;9051;351.8;2.4;192.168.1.145;44537;software20.org;80;yes;ThuDec113;50;51.8373732011;ThuDec113;51;11.4517212011;0;00;19.614348;455;185;270;184;270;5;267;2772;383480;3;0;3;0;1/4;1/1;0;0;0;0;141;19551;346.2;2.9;

output:

192.168.1.145;44535;software20.org;80;yes;ThuDec113;50;50.8384422011;ThuDec113;50;57.2764792011;0;00;06.438037;58;29;29;28;29;1;25;526;36045;0;0;0;0;1/1;1/1;0;0;0;0;82;5599;346.4;1.6;
192.168.1.145;44536;software20.org;80;yes;ThuDec113;50;51.5587192011;ThuDec113;51;10.7557082011;0;00;19.196988;224;97;127;96;127;7;124;3963;173749;3;0;3;0;1/4;1/1;0;0;0;0;206;9051;351.8;2.4;
192.168.1.145;44537;software20.org;80;yes;ThuDec113;50;51.8373732011;ThuDec113;51;11.4517212011;0;00;19.614348;455;185;270;184;270;5;267;2772;383480;3;0;3;0;1/4;1/1;0;0;0;0;141;19551;346.2;2.9;

thanks for your pointer...

Looks like you wanted 37 fields, not 29.

perl -ne '@x=split/;/,$_;$i=1;for(@x){print "$_\;";if($i==37){print "\n";$i=0} $i++}' input.txt

alright, thank you. I'll learn your code and maybe try using awk as alternative. :slight_smile: