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
If I understand what you're trying to do correctly, then
echo '1,2,3,4,5,6,7,8,9,10' | sed 's/\([^,]*,[^,]*\),/\1\n/g'
seems like the most straightforward way. \([^,]*,[^,]*\) will capture 1,2, 3,4, and so forth, and the commas between them are replaced with newlines through the usual s///g. This will print
1,2
3,4
5,6
7,8
9,10