Skip to main content
Tweeted twitter.com/#!/StackUnix/status/291848143061004288
Formatting and tag
Source Link
jasonwryan
  • 74.8k
  • 35
  • 204
  • 230

Awk: expanding first field along the column

I have a task wichwhich requires some awk scripting:

Lets say I have a file:

A,under1 ,under2 ,under3 ,under4 ,under5 B,new1 ,new2 ,new3 C,sm1 ,sm2

A,under1
,under2
,under3
,under4
,under5
B,new1
,new2
,new3
C,sm1
,sm2

How could I make it look like this using awk?

A,under1 A,under2 A,under3 A,under4 A,under5 B,new1 B,new2 B,new3 C,sm1 C,sm2

A,under1
A,under2
A,under3
A,under4
A,under5
B,new1
B,new2
B,new3
C,sm1
C,sm2

In other words, I want to expand first field along the column.

Thanks for the help!

Awk expanding first field along the column

I have a task wich requires some awk scripting:

Lets say I have a file:

A,under1 ,under2 ,under3 ,under4 ,under5 B,new1 ,new2 ,new3 C,sm1 ,sm2

How could I make it look like this using awk?

A,under1 A,under2 A,under3 A,under4 A,under5 B,new1 B,new2 B,new3 C,sm1 C,sm2

In other words, I want to expand first field along the column.

Thanks for the help!

Awk: expanding first field along the column

I have a task which requires some awk scripting:

Lets say I have a file:

A,under1
,under2
,under3
,under4
,under5
B,new1
,new2
,new3
C,sm1
,sm2

How could I make it look like this using awk?

A,under1
A,under2
A,under3
A,under4
A,under5
B,new1
B,new2
B,new3
C,sm1
C,sm2

In other words, I want to expand first field along the column.

Source Link

Awk expanding first field along the column

I have a task wich requires some awk scripting:

Lets say I have a file:

A,under1 ,under2 ,under3 ,under4 ,under5 B,new1 ,new2 ,new3 C,sm1 ,sm2

How could I make it look like this using awk?

A,under1 A,under2 A,under3 A,under4 A,under5 B,new1 B,new2 B,new3 C,sm1 C,sm2

In other words, I want to expand first field along the column.

Thanks for the help!