awk seems to match all the patterns matching an expression and executes the corresponding actions. Is there a precedence that can be associated ?
For eg. In the below, lines starting with # (comments) are matched by both patterns, and both actions are executed. I want commented lines to match only the first action.
/^#.*/ {
// Action for lines starting with '#'
}
{
// Action for other lines
}
If you want to keep the code you already have mostly intact, you could just use the
awknext statement. Once you encounter thenextstatement,awkskips processing the current record and goes to the next line.So if you put
nextinto the bottom your 1st block the 2nd block wouldn’t be executed.