{"id":1861,"date":"2014-02-28T18:42:45","date_gmt":"2014-02-28T18:42:45","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=1861"},"modified":"2014-03-03T12:55:43","modified_gmt":"2014-03-03T12:55:43","slug":"covert-case-in-bash","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=1861","title":{"rendered":"Convert case in Bash"},"content":{"rendered":"<h3><a href=\"http:\/\/en.wikipedia.org\/wiki\/Tr_%28Unix%29\">tr<\/a><\/h3>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">$ echo $a | tr '[:upper:]' '[:lower:]'<br \/>\nhi all<\/div><\/div>\n\n<\/pre>\n<h3><a href=\"http:\/\/en.wikipedia.org\/wiki\/AWK\">AWK<\/a><\/h3>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">$ echo $a | awk '{print tolower($0)}'<br \/>\nhi all<\/div><\/div>\n\n<\/pre>\n<h3><a href=\"https:\/\/en.wikipedia.org\/wiki\/Bash_%28Unix_shell%29\">Bash 4.0<\/a><\/h3>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">$ echo ${a,,}<br \/>\nhi all<\/div><\/div>\n\n<\/pre>\n<h3><a href=\"http:\/\/en.wikipedia.org\/wiki\/Perl\">Perl<\/a><\/h3>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">$ echo $a | perl -ne 'print lc'<br \/>\nhi all<\/div><\/div>\n\n<\/pre>\n<h3><a href=\"https:\/\/en.wikipedia.org\/wiki\/Bash_%28Unix_shell%29\">Bash<\/a><\/h3>\n<pre>\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">lc(){<br \/>\n&nbsp; &nbsp; case &quot;$1&quot; in<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; [A-Z])<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; n=$(printf &quot;%d&quot; &quot;'$1&quot;)<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; n=$((n+32))<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; printf \\\\$(printf &quot;%o&quot; $n)<br \/>\n&nbsp; &nbsp; esac<br \/>\n}<br \/>\nword=&quot;ABX&quot;<br \/>\nfor((i=0;i&amp;lt;${#word};i++))<br \/>\ndo<br \/>\n&nbsp; &nbsp; ch=${word:$i:1}<br \/>\n&nbsp; &nbsp; lc $ch<br \/>\ndone<\/div><\/div>\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>tr $ echo $a | tr &#8216;[:upper:]&#8217; &#8216;[:lower:]&#8217; hi all AWK $ echo $a | awk &#8216;{print tolower($0)}&#8217; hi all Bash 4.0 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1861","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1861","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1861"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1861\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1861"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}