
On Thu, Nov 17, 2011 at 15:56, Peter Ross <Peter.Ross@bogen.in-berlin.de> wrote:
Hi Markus,
in principle it works, you can put all stuff in one line and run it between single quotes as a awk command line.
There is a little script doing this for you:
cat $my_awk_file | awk '{if (NR>1) for (i=1; i<=NF; i++) printf $i" "}'
In general it works, however, you have to escape the single quotes _inside_ the script.
"'" has to be written as "'"'"'"
Well, that syntax hurts;-) especially if you want to write a awk line that processes an awk script to get an awk line..
And than you get:
cat $my_awk_file | \ awk -F"'" '{for (i=1; i<NF; i++) printf $i"'"'"'""\"""'"'"'""\"""'"'"'"; print $NF}' | \ awk '{if (NR>1) for (i=1; i<=NF; i++) printf $i" "}'
The appearing output as a command line to do what the awk script does:
cat $my_file | awk '{ if ($1=="Repo-name") {printf "'"'"'"; for (i=3; i<NF; i++) printf $i" "; printf $NF"'"'"' "} if ($1=="Repo-baseurl") { url=1; comma=match($NF,","); if (comma) out=substr($NF,1,comma-1); else out=$NF; printf "'"'"'"out"'"'"' "; } else { if (url==1) { if ($1==":") { comma=match($NF,","); if (comma) out=substr($NF,1,comma-1); else out=$NF; printf "'"'"'"out"'"'"' "; } else {url=0; print "";} } } }'
Well, that's all in one line now - but who can read that?
Agreed, it's a bit unwieldy!
Feel free to use whatever you like;-)
Will continue to investigate options, thanks again for your help, at least I have something that works now :) Marcus.