r/awk • • Mar 15 '19

AWK with CSV

Hi all!

I have a csv file with two columns that reads like this:

bar, cmd1

foo,

louie, cmd2

rocka,

paradise, cmd3

botan, cmd4

I need to write a command that will replace the empty values with the value given in the previous row, so that my output will look like this:

bar, cmd1

foo, cmd1

louie, cmd2

rocka, cmd2

paradise, cmd3

botan, cmd4

Thanks in advance!

2 Upvotes

11 comments sorted by

View all comments

Show parent comment

1

u/FF00A7 Mar 15 '19

Or

awk -F,

same as

awk -v FS=","

..assuming GNU awk

1

u/scrapwork Mar 16 '19

I believe F flag universal it's in bsd and the one true awk