sed - awk replace serialized number lines and move up other lines -


i have file has following format

1 - descrio #944 name address 2 - desanother #916  name address 3 - somedes #957  name address 

and want output as,

usercode #944, name, address usercode #916, name, address usercode #957, name, address  

with awk

awk 'nr%3 == 1{sub(/^.*#/, "usercode #")};{ors=nr%3?", ":"\n"};1' file usercode #944, name, address usercode #916, name, address usercode #957, name, address 

for variable number of rows

awk -v rs='(^|\n)[[:digit:]]+[[:blank:]]*-[[:blank:]]*' '{sub(/\n$/, ""); gsub(/\n/, ", "); printf "%s", $0""rt}end{print ""}' file 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -