sed - Add columns with default values into csv file -


i want use sed add columns below csv file default value.

my file like:

40,2012-05-30,london,61,sunny 41,2012-02-22,moscow,11,snow 54,2012-04-10,tokyo,02,sunny 

i want output be:

40,2012-05-30,null,london,null,null,61,sunny,tom 41,2012-02-22,null,moscow,null,null,11,sunny,tom 54,2012-04-10,null,tokyo,null,null,02,sunny,tom 

what best sed or awk commands desired output?

$ awk '{print $1,f,$2,f,f,$3,$4,$5,"tom"}' fs=, ofs=, f='null' file 40,null,2012-05-30,null,null,london,61,sunny,tom 41,null,2012-02-22,null,null,moscow,11,snow,tom 54,null,2012-04-10,null,null,tokyo,02,sunny,tom 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

javascript - Backbone.js getting target attribute -

html - Repeat image to extend header to fill screen -