A task that comes up every so often, for some reason
Archive of posts tagged text processing
Smart ranges in awk
Using flags to select ranges in awk
“Zero or more”
This usually comes up in a form similar to "I'm running this code: $ echo "foobar 123" | sed 's/[0-9]*/blah/' blahfoobar 123 but I don't get the expected result!" (which they think should be "foobar blah"). The result they get is instead as shown above. Why is that? Remember that the star quantifier "*" means […]
Sorting by paragraph
This comes up in discussions and forums from time to time. Basically, the input is composed of paragraphs (ie, separated by runs of empty lines), and each paragraph has a specific value somewhere in it. The goal is to sort the text "by paragraph", according to this key, and the resulting output should still consist […]
Working with blocks in awk
Recognize multiline blocks of text using awk