I have a file which is :
line1
line2
line3
What I am trying to have is
"line1"{
"line1"
}
I am trying to do this using awk but I don't know how to use the special characters. For now I have this.
awk '{ "$0" {"$0"} }'
$ awk '{$0="\""$0"\""; print $0 "{\n" $0 "\n}"}' file
"line1"{
"line1"
}
"line2"{
"line2"
}
"line3"{
"line3"
}
$ awk -v q='"' '{ql = q $0 q; print ql "{" ORS ql ORS "}" }' ip.txt
"line1"{
"line1"
}
"line2"{
"line2"
}
"line3"{
"line3"
}
-v q='"' save the double quote character in variable named q, makes it easier to insert double quotes instead of messing with escapesql = q $0 q this adds double quotes around the input recordql "{" ORS ql ORS "}" required output, ORS is output record separator which is newline character by default
" }" to get a space before } in the outputIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With