Would appreciate some help again please

My file looks like:hed, hed2, hed3, hed4, hed5, hed6

1,fiea1 1, fiea1 2, fiea1 3, fiea1 4, last fiea1

1,fieb1 1, fieb1 2, fieb1 3, fieb1 2, last fieb1

2,fieb2 1, fieb2 2, fieb2 3, fieb2 4, last fieb2

1,fiec1 1, fiec1 2, fiec1 3, fiec1 4, last fiec1

2,fiec2 1, fiec2 2, fiec2 3, fiec2 4, last fiec2

1,fiedd 1, fiedd 2, fiedd 3, fiedd 4, last fiedd

1,fiee1 1, fiee1 2, fiee1 3, fiee1 4, last fiee1

2,fiee2 1, fiee2 2, fiee2 3, fiee2 4, last fiee2Is there a way please of joining the second line conditionally?

I would like to see:1,fiea1 1, fiea1 2, fiea1 3, fiea1 4, last fiea1

1,fieb1 1, fieb1 2, fieb1 3, fieb1 2, last fieb1 last fieb2

1,fiec1 1, fiec1 2, fiec1 3, fiec1 4, last fiec1 last fiec2

1,fiedd 1, fiedd 2, fiedd 3, fiedd 4, last fiedd

1,fiee1 1, fiee1 2, fiee1 3, fiee1 4, last fiee1 last fiee2The file is not fixed length but is delimited by commas

Not fussy on how this is achieved - any solution will be grateful: sed, awk, perl, cut of line2 and a joinWill continue seeking a solution myself

Many thanks in anticipation.

I will get you started. This awk program sets the field seperator to comma and skips the first line: awk ' BEGIN { FS="," } { # skip the first line if(NR == 1) continue # this below would print the entire line and a carriage return # printf("%s\n", $0) # line below prints field 1 with no CR printf("%s", $1) } ' datafileNow, all you have to do is determine what to do if field 1 equals == a 1 or a 2.

That's great, thanks, nails.I will give it a go as I need to be able to think around the problem for myself. Hope to come up with something that will work.

C

Ask Your Question

Weekly Poll

Do you think SpaceX laying off some of its workforce will help it succeed?

Discuss in The Lounge

Poll History