I have a file w/ a thousand lines that looks like this:
9 9 9
9 9 9
9
9 9 9
9 9 9
9
I want to join lines in sets of 3 to produce:
9 9 9 9 9 9 9
9 9 9 9 9 9 9
I thought I'd use sed to replace every 3rd newline with an "X", then join all the lines (:%j in vim), then replace the "X" with new lines.
I tried to use sed to replace every 3rd newline with "X", and it doesn't replace anything:
sed -e "s/\n/X/3" test.txt > test2.txt
I tried \r and \r\n instead of \n, to no avail. It appears sed just is not matching the newline chars. I'm on a Mac. What can I do to match newlines?
Thanks.