printing - Read a file and based on condition perform some write operation -


i newbie awk. searched on figure out myself , failed. last resort. please help.

i have file big follows;

*set      7 636322    635890    632043    632044 636323    636322    632044    632045 *set      8 636315    636323    632045    632046 *set      9 635890    635889    635992    635994 635994    635992    635991    635993 635995    635991    635992    635996 635996    635992    635889    635888 

i'd make this

1    636322    635890    632043    632044 1    636323    636322    632044    632045 2    636315    636323    632045    632046 3    635890    635889    635992    635994 3    635994    635992    635991    635993 3    635995    635991    635992    635996 3    635996    635992    635889    635888 

basically have condition string 'set' , skip line add count-id in first column, print rest of line continue until sees next 'set'. go on till end of file. in advance.

awk '/set/ { counter++ }      nf == 4 {printf("%d\t%s\n", counter, $0); }' 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -