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
Post a Comment