Setting variables in awk according to matching pattern
How can I construct a pattern in `awk` then seh a value for a variable.
I would like to match the following patterns Code:
^[[:space:]]*(#;!)+[[:space:]]*Mode: org$ |
why do you open a new thread for this?
Code:
/pattern/ { var=value } |
Basically to make the task simpler rather than reading through a lot of things.
|
Or throw in a logical OR using the || operator.
Code:
/^[[:space:]]*(#;!)+[[:space:]]*Mode: org$/ \ |
Why does it not work like this?
Code:
charcl='^[[:space:]]*([#;!]+|@c|\/\/)[[:space:]]*' |
Please show the AWK script in which that line is to be found so that the context is known.
|
Code:
capture () Code:
charcl='^[[:space:]]*([#;!]+)[[:space:]]*' |
when you use sub with a variable you must not use / :
Code:
found { sub(ccls,""); print } |
Works very well, thank so very much. Is there a way to add an empty line between blocks (one block is identified by the lines enclosed within `begorg` and`endorg`)?
|
Yes, it would be with a print() or printf() function. Add that to the appropriate stanza.
|
Have used `print ""` to print a blank line. Introduced it on the line checking `endrsc`.
Code:
$0 ~ endrsc { insc=0; print "" } |
All times are GMT -5. The time now is 11:26 AM. |