I have a command I execute: awk 'BEGIN { ORS=" " } { print "\"" $1 "\"" }' input_file which gives me exactly what I need, all field one's in quotes on one line each separated by one space. I now need to print a single quote around all of this, but the ORS flag is screwing me up, it's causing every attempt I try to repeat for every record. Anyone got a pointer how to do this? Thanks! jlc
From: Joseph L. Casale <JCasale at activenetwerx.com>> I have a command I execute: > awk 'BEGIN { ORS=" " } { print "\"" $1 "\"" }' input_file > which gives me exactly what I need, all field one's in quotes on one line > each separated by one space. I now need to print a single quote around all > of this, but the ORS flag is screwing me up, it's causing every attempt I > try to repeat for every record.awk -v q="'" ' BEGIN { ORS=" "; printf("%s", q) } { print "\"" $1 "\"" } END { printf("%s", q) } ' or awk ' BEGIN { ORS=" "; printf("\x27") } { print "\"" $1 "\"" } END { printf("\x27") } ' JD
Apparently Analagous Threads
- [RFC] Extension to TableGen's AssemblerPredicates to support combining features with ORs
- awk global replacement only after keyword
- replace a few strings in a text file
- incorrect multiple outputs
- [PATCH 1/2] builder: add an optional suffix string for INI parsing errors