| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
On 2017-05-22 18:16, 'Van Handel' [email protected] [sed-users] wrote:
> 00:12:34:56:78:9A
> 101
> 123456
> 00:21:CE:54:22:7A
> 101
> 876543
> 00:21:32:43:54:87
> 1
> 234
>
> I would like to combine this output 3 lines at a time, like:
>
> 00:12:34:56:78:9A 101 123456
> 00:21:CE:54:22:7A 101 876543
> 00:21:32:43:54:87 1 234
>
> Is there a way to do this using sed?
Yes:
sed 'N;N;s/\n/ /g' input.txt > output.txt
Change the space to whatever delimiter you want, such as tabs:
sed 'N;N;s/\n/\t/g' input.txt > output.txt
It doesn't gracefully handle any edge conditions where a field is
missing, but could be massaged to be a little smarter if needed.
-tim