Help with arranging data file

Dears,

I have the below data,

sss-aaaaaa
111211 222222 33333 22222 1163111
sss-vvvvvv
111311 224522 335633 24322 111511
sss-cccccc
111221 224522 333333 24322 111511
sss-dddddd
111211 222222 33333 22345222 113111

I want to make them like

sss-aaaaaa 111211 222222 33333 22222 1163111

sss-vvvvvv 111311 224522 335633 24322 111511

sss-cccccc 111221 224522 333333 24322 111511

sss-dddddd 111211 222222 33333 22345222 113111

Best Regards

nawk 'ORS=(FNR%2)?FS:RS' myFile

doesn't work :frowning:

Work's for me :slight_smile:
Try to provide some info about your enviroment !

1 - This smells like homework

2 - It works for me, and I don't have a clue what the nawk command is doing. (Heck, up until a couple days ago, I never even knew about the nawk command.)

I changed the shell and it worked, thanks a lot,
could you explain this code for me, Im new to unix and I feel that this is 2 much for me :smiley:
By the way Mr. Dave, this is not a home work, this is a part of my job duties !!!

ORS - OutputRecordSeparator
FNR - FileNumberRecord counter
FS - FieldSeparator
RS - RecordSeparator (similar to ORS, but for INPUT)

(FNR%2) - modulo of 2 of the current record/line number

if ( modulo of 2 of the current record/line number) is not '0' (odd record/line number), assign a value of 'FS' to ORS (space by default) - this joins 2 sequencial lines. Otherwise, assign the value of RS (new line by default) to ORS - this goes to the next line of output.

Because there's no explicit action associated with the 'if/test' condition, the default action is to print the current record/line.

So what happens is we keep joining the TWO adjacent lines to each other. If you change '2' to '3' - you'll be joining THREE adjacent lines of input to ONE line of output.

Thanksssssssss a lot, :b: