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.
awkvariables as command paramaters vs. as command ooptions, see: Are there 2 ways to set awk vars via command line?. The-v(option) syntax was introduced to deal with potential pitfalls of the paramater method shown in the two (current) answers.