Single entry has multiple lines. Each entry is separated by two blank lines. Each entry has to be made into a single line followed by a delimiter(;).
Sample Input:
Name:Sid
ID:123
Name:Jai
ID:234
Name:Arun
ID:12
Tried replacing the blank lines with cat test.cap | tr -s [:space:] ';'
Output:
Name:Sid;ID:123;Name:Jai;ID:234;Name:Arun;ID:12;
Expected Output:
Name:SidID:123;Name:JaiID:234;Name:ArunID:12;
Same is the case with Xargs
.
I've used sed
command as well but it only joined two lines into one. Where as I've 132 lines as one entry and 1000 such entries in one file.
You may use
Output:
Notes:
FS = "\n"
will set field separators to a newline`RS = "\n\n"
will set your record separators to double newlinegsub(/\n/, "", $0)
will remove all newlines from a found recordsed 's/;;*$//'
will remove the trailing;
added byawk
See the online demo