M
M
Maxim Sandakov2020-03-30 12:06:03
linux
Maxim Sandakov, 2020-03-30 12:06:03

How to concatenate every 3 lines in Bash?

Good afternoon
There is a following task. There is a text file with a list of equipment in this format
host_name <hardware identifier in the system>
alias <hardware model>
address <"ip address">

And so it is repeated for each piece of iron. It is necessary to merge every three lines into one, but I'm still just learning bash scripts and I can't figure out how to do this, either somehow in cycles or through sed.
Thank you in advance for your help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2020-03-30
@Lithium02

it will be difficult through sed, since it reads line by line and trims the end of the line itself.
Try this, head-on:

while read; do echo -n "$REPLY";read;echo -n " $REPLY";read;echo -n " $REPLY";echo""; done < имя_файла

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question