Purely using GNU sed substitution:
sed 's/\(\([^;]*;\)\{5\}\)/\1\n/g' or without all the escaping backslashes using -E (thanks @JoL):
sed -E 's/(([^;]*;){5})/\1\n/g' Example:
$ cat test.txt a;a;a;a;a;a;a;a;a;a;a;a;a;a;a;a;a;a;a;a;a;a;a;a; etc...... $ cat test.txt | sed 's/\(\([^;]*;\)\{5\}\)/\1\n/g' a;a;a;a;a; a;a;a;a;a; a;a;a;a;a; a;a;a;a;a; a;a;a;a; etc...... Explanation:
\([^;]*;\): regex capture group matching all characters up to and including a semi-colon.\(\([^;]*;\)\{5\}\): regex capture group matching five occurrences of the above. In thesedcommand, this will be matched into\1.s/\(\([^;]*;\)\{5\}\)/\1\n/g: substitute (s/) every occurrence (/g) of the group of five occurrences of all characters up to and including a semicolon (\(\([^;]*;\)\{5\}\)) with itself (\1), but followed by a newline character (\n).