Using sed to make indexes for books (1997)
pement.org
pement.org
The non-artistic remark is subjective--I'm imagining those with a strong inclination towards regular expressions should find this fairly straight forward.
There's a script I use every day that takes the current date as an integer, calculates an offset, reads line of a Bible reading plan e.g. "Acts 19:1-20 Paul in Ephesus", gets the chapter number "Acts 19", and then links me to that file. I use sed to get the text between* the start and ":". I first wrote it in AppleScript on a Mac, but later I wanted to port it to a jailbroken iPhone. awk wasn't there, but sed was.
I also used sed for a Mac/Linux cross-platform script that scraped EPG data from MC2XML (information about TV guides). sed was faster than awk.
In practice these days I usually just use TextWrangler and find-replace with Regex, instead of writing a script.
* If you think you can do textBetween faster - please contribute your own implementation over on Rosetta Code.
I don't want to pay for BBEdit though, and I'm still on 10.9 so the compatibility hasn't caused problems for me yet.
”Do I have to pay to use BBEdit?
No. You can use BBEdit without purchasing a license, in the same way you’ve been using TextWrangler (yes, for free). If you want BBEdit’s complete feature set (web authoring tools, and other exclusive features), you can purchase a license any time you like.”
They also claim that gives you more than TextWrangler’s feature set (https://www.barebones.com/products/bbedit/comparison.html). If they didn’t add nagging for upgrades, it seems they simply renamed TextWrangler to BBEdit.
I have seen some programmers quoted as saying they believe writing programs is "art". I think one of the interviews with Arthur Whitney has him saying writing programs is analogous to writing poetry.
Assuming one does not use backtracking as is done by Pement here, IME, the speed of sed routinely beats other, larger scripting languages for many tasks.
The basic functionality of many unix utilities can be replicated using sed, e.g. tee, etc.
When one considers the small size and simplicity of this program, and that it is probably as commonly found on unix operating systems as echo, ls or cd, knowing how to read and write sed can be very useful.
O'Reilly have an excellent book: "sed & awk Book by Arnold Robbins and Dale Dougherty"
For awk, there is the classic book:"The AWK Programming Language by Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger"
UNIX Power Tools may or may not be one of them, but remains a phenomenal book. It's what got me "over the hump" in grokking Unix and how it and its tools worked, many, many moons ago.
Larry Peek is a God.