Using sed to Create Book Indexes: Lessons from a Publishing Workflow
Using sed to make indexes for books (long)
I needed to automate book index creation after typesetting, moving from manual entry to a sorted file. While an awk script worked, I discovered a more concise sed solution. However, a single formatting error in the input could break the entire process. I explain how the script fails and offer a robust fix to validate data before processing.
If one line anywhere in the file was in error, the script would fail to change every other line after that.
- tomhow
Previously:
Using sed to make indexes for books (1997) - https://news.ycombinator.com/item?id=16080505 - Jan 2018 (17 comments)
- janandonly
Two thought:
1. I feel the use of AWK, SED, GREP and Bash (to name a few) is general waning. I rarely see it outside of HN posts. I wish I were better at using it. Sometimes for a special need I’ll ask a LLM to write me a script in bash just to keep this spirit alive.
2. On the other hand, I’ve written a book and added an index by using Microsoft Word, and it was basically pretty easy to add. I don’t know why I should want to go back to a world of intricate command line tools to do a job that should just be easy enough?