Tim Chase<p>My love for <a href="https://mastodon.bsd.cafe/tags/plaintext" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>plaintext</span></a> and <a href="https://mastodon.bsd.cafe/tags/awk" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>awk</span></a> (as well as other Unix text-processing tools) was rejuvenated by a recent nerdsnipe¹ problem someone shared.</p><p>They had a WordGrinder² file which is a container-type format that can hold multiple documents (such as multiple individual chapters of a book) in the same document file. As far as we could tell, there's no native way to flatten all those sub-documents into a flat single file, and there was no way to export them into a multipart output document.</p><p>Fortunately, that WordGrinder file format is just plaintext. It didn't take more than ~10 minutes to reverse-engineer the basics of the file-format and then cobble together an awk(1) one-liner to do the flattening. Worked perfectly on the first try.</p><p>⸻<br>¹ <a href="https://www.reddit.com/r/commandline/comments/1nkxz4t/is_there_any_way_to_massexport_a_document_set_in/" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://www.</span><span class="ellipsis">reddit.com/r/commandline/comme</span><span class="invisible">nts/1nkxz4t/is_there_any_way_to_massexport_a_document_set_in/</span></a></p><p>² <a href="http://cowlark.com/wordgrinder/index.html" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">http://</span><span class="ellipsis">cowlark.com/wordgrinder/index.</span><span class="invisible">html</span></a></p>