I have this line for example:
1,2,3,4,5,6,7,8,9,10
I want to insert a newline (\\n) every 2nd occurrence of \",\" (replace the 2nd, with ne
Can't add comment to wintermutes answer but it doesn't need the first ,
section as it will have to have had a previous field to be comma separated.
sed 's/\(,[^,]*\),/\1\n/g'
Will work the same
Also I'll add another alternative( albeit worse and leaves a trailing newline)
echo "1,2,3,4,5,6,7,8,9,10" | xargs -d"," -n2 | tr ' ' ','