It's not straightforward, but it can be done.
Archive of posts filed under the awk category.
The mythical “idempotent” file editing
Stop asking for that.
“Range of fields” in awk
This is asked very often, and the solution isn't always obvious (if at all).
Three text processing tasks
Unlikely to help someone, but anyway.
Pulling out strings
Some ways to "pull out" strings from files