{"id":2450,"date":"2018-11-03T09:24:18","date_gmt":"2018-11-03T09:24:18","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=2450"},"modified":"2018-11-04T08:19:43","modified_gmt":"2018-11-04T08:19:43","slug":"normalizing-filenames-and-data-with-bash-linux-com","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/11\/03\/normalizing-filenames-and-data-with-bash-linux-com\/","title":{"rendered":"Normalizing Filenames and Data with Bash | Linux.com"},"content":{"rendered":"<p>URLify: convert letter sequences into safe URLs with hex equivalents.<\/p>\n<p>This is my 155th column. That means I&#8217;ve been writing for <em>Linux Journal<\/em> for:<\/p>\n<p>$ echo &#8220;155\/12&#8221; | bc<br \/>\n12<\/p>\n<p>No, wait, that&#8217;s not right. Let&#8217;s try that again:<\/p>\n<p>$ echo &#8220;scale=2;155\/12&#8221; | bc<br \/>\n12.91<\/p>\n<p>Yeah, that many years. Almost 13 years of writing about shell scripts and lightweight programming within the Linux environment. I&#8217;ve covered a lot of ground, but I want to go back to something that&#8217;s fairly basic and talk about filenames and the web. &#8230;<\/p>\n<p>So purely as an exercise in scripting, let&#8217;s write a script that converts any string you hand it into a &#8220;web-safe&#8221; sequence. Before starting, however, pull out a piece of paper and jot down how you&#8217;d solve it.<\/p>\n<p>Normalizing Filenames for the Web<\/p>\n<p>My strategy is going to be easy: pull the string apart into individual characters, analyze each character to identify if it&#8217;s an alphanumeric, and if it&#8217;s not, convert it into its hexadecimal ASCII equivalent, prefacing it with a &#8220;%&#8221; as needed.<\/p>\n<p>Read more at <a href=\"https:\/\/www.linuxjournal.com\/content\/normalizing-filenames-and-data-using-bash-string-variable-manipulations\">Linux Journal<\/a><\/p>\n<p><a href=\"https:\/\/www.linux.com\/learn\/normalizing-filenames-and-data-bash\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>URLify: convert letter sequences into safe URLs with hex equivalents. This is my 155th column. That means I&#8217;ve been writing for Linux Journal for: $ echo &#8220;155\/12&#8221; | bc 12 No, wait, that&#8217;s not right. Let&#8217;s try that again: $ echo &#8220;scale=2;155\/12&#8221; | bc 12.91 Yeah, that many years. Almost 13 years of writing about &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/11\/03\/normalizing-filenames-and-data-with-bash-linux-com\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Normalizing Filenames and Data with Bash | Linux.com&#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":[1],"tags":[],"class_list":["post-2450","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/2450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=2450"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/2450\/revisions"}],"predecessor-version":[{"id":2549,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/2450\/revisions\/2549"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=2450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=2450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=2450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}