{"id":34597,"date":"2025-08-18T15:38:24","date_gmt":"2025-08-18T20:38:24","guid":{"rendered":"https:\/\/www.allyngibson.com\/?p=34597"},"modified":"2025-08-18T15:38:24","modified_gmt":"2025-08-18T20:38:24","slug":"a-little-ingenuity-and-a-bit-of-code-make-the-world-go-round","status":"publish","type":"post","link":"http:\/\/www.allyngibson.com\/?p=34597","title":{"rendered":"A Little Ingenuity and a Bit of Code Make the World Go Round"},"content":{"rendered":"<p>Sometimes I surprise myself with my own cleverness and creativity.  Case in point&#8230;<\/p>\n<p>At Diamond, we maintain two completely different SKU systems to refer to inventory.  There&#8217;s a stock code system (prefixed STK or STL), and there&#8217;s an item code system (prefixed in a MMMYY system, such as SEP25).  Occasionally over the years I&#8217;ve been asked why this is, and I have no answer.  It was a data design decision made long before I started working for Diamond, and as with many things in the world, it worked and continued on its own inertia.  I recall conversations pre-COVID that to standardize on one system, probably the stock code system, would &#8220;take three years&#8221; to develop.<\/p>\n<p>&#8220;Three years&#8221; was the timeframe for a lot of things.<\/p>\n<p>Anyway.<\/p>\n<p>I had a Word document that was filled with stock codes.  About 150 items total.  I had a spreadsheet with both stock codes and item codes.  I needed to change the stock codes to item codes in the Word document.  And doing it manually &#8212; looking up the stock code, replacing the stock code with the item code in the document &#8212; would take time.<\/p>\n<p>&#8220;<i>Y&#8217;know<\/i>,&#8221; I thought, &#8220;<i>there&#8217;s the Linux <code>sed<\/code> command.  That can replace text in a text file from the command line, and you don&#8217;t even have to open the file<\/i>&#8230;&#8221;<\/p>\n<p>But I didn&#8217;t have a text file.  I had a Microsoft Word document.  Sure, there&#8217;s <i>text<\/i> in the Word document, unless Word did something to compress it or do weird formatting things with it.  Would <code>sed<\/code> work on that?<\/p>\n<p>Well, there was only one way to find out&#8230;<\/p>\n<p>I had my Word document, and I cobbled together the necessary command to try the first stock code I had to change&#8230;<\/p>\n<p><code>sed -i 's\/STL382233\/SEP250250\/g' manga.doc<\/code><\/p>\n<p>I ran the command in my terminal.  I opened the document &#8212; if you can read the <code>sed<\/code> command, yes, it&#8217;s a document about manga &#8212; and looked to see&#8230;<\/p>\n<p>It worked!  It worked!<\/p>\n<p>As I said, I had a spreadsheet with both stock codes and item codes, and from there it was a trivial matter of writing a <code>=CONCATENATE<\/code> function to write all the <code>sed<\/code> commands I needed, which I would then run as a bash script in terminal.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"674\" height=\"549\" src=\"http:\/\/www.allyngibson.com\/wp-content\/uploads\/2025\/08\/Screenshot_20250818_122509.jpg\" alt=\"Screenshot of my bash script in my text editor, showing about a dozen and a half sed commands\" class=\"aligncenter size-full wp-image-34596\" \/><\/p>\n<p>The script was run!  The codes were changed, from stock to item!<\/p>\n<p>Many hours of tedious work was avoided.<\/p>\n<p>And I was still only on my first cup of coffee for the day.<\/p>\n<p>Even I am staggered sometimes by my own ingenuity.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes I surprise myself with my own cleverness and creativity. Case in point&#8230; At Diamond, we maintain two completely different SKU systems to refer to inventory. There&#8217;s a stock code system (prefixed STK or STL), and there&#8217;s an item code system (prefixed in a MMMYY system, such as SEP25). Occasionally over the years I&#8217;ve been<a class=\"more-link\" href=\"http:\/\/www.allyngibson.com\/?p=34597\">Continue reading <span class=\"screen-reader-text\">&#8220;A Little Ingenuity and a Bit of Code Make the World Go Round&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[229],"tags":[4846,5140,5277,426],"class_list":["post-34597","post","type-post","status-publish","format-standard","hentry","category-work","tag-diamond-comic-distributors","tag-linux","tag-microsoft","tag-microsoft-word","entry"],"_links":{"self":[{"href":"http:\/\/www.allyngibson.com\/index.php?rest_route=\/wp\/v2\/posts\/34597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.allyngibson.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.allyngibson.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.allyngibson.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.allyngibson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=34597"}],"version-history":[{"count":0,"href":"http:\/\/www.allyngibson.com\/index.php?rest_route=\/wp\/v2\/posts\/34597\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.allyngibson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=34597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.allyngibson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=34597"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.allyngibson.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=34597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}