I'm new to awk. I have a ConTeXt file where I'm using
"\startconcept{foo:}" and "\startconcept{foo}" interchangeably. I'd
like to make all of them look like the former with the ":". I
developed the following which prints only the lines without the colon:
"gawk /startconcept.*[^:]\}/ path/to/file", but I can't figure out how
to replace the right "}" with ":}". I had hoped to use the "sub"
function but I can't get it to work.
Any suggestions?
Thanks.
Scot
Why is your awk program unquoted?
Is there only one matching expression per line?
> to replace the right "}" with ":}". I had hoped to use the "sub"
> function but I can't get it to work.
>
> Any suggestions?
Try
gawk '/startconcept.*[^:]\}/ { sub(/}/,":}") }
{ print $0 }' /path/to/file
Janis
>
> Thanks.
>
> Scot
Scot
That would have an undesired effect on lines that have a "}" before the matching
pattern, e.g.
...} startconcept{foo}
I'd just use:
awk '{sub(/\\startconcept{foo}/,"\\startconcept{foo:}")}1' /path/to/file
Regards,
Ed.
...} startconcept{foo}
in the document.
Thanks!
Scot