{"id":882,"date":"2014-10-28T13:05:22","date_gmt":"2014-10-28T13:05:22","guid":{"rendered":"http:\/\/naich.net\/wordpress\/?p=882"},"modified":"2014-10-31T15:07:10","modified_gmt":"2014-10-31T15:07:10","slug":"bash-brackets","status":"publish","type":"post","link":"https:\/\/naich.net\/wordpress\/index.php\/bash-brackets\/","title":{"rendered":"Bash Brackets"},"content":{"rendered":"<p>Handy guide to bash brackets, swiped from Stackoverflow.<\/p>\n<p><strong>Brackets<\/strong><\/p>\n<pre>if [ CONDITION ]    Test construct  \r\nif [[ CONDITION ]]  Extended test construct  \r\nArray[1]=element1   Array initialization  \r\n[a-z]               Range of characters within a Regular Expression<\/pre>\n<p><strong>Curly Brackets<\/strong><\/p>\n<pre>${variable}                             Parameter substitution  \r\n${!variable}                            Indirect variable reference  \r\n{ command1; command2; . . . commandN; } Block of code  \r\n{string1,string2,string3,...}           Brace expansion  \r\n{a..z}                                  Extended brace expansion  \r\n{}                                      Text replacement, after find and xargs<\/pre>\n<p><strong>Parentheses<\/strong><\/p>\n<pre>( command1; command2 )             Command group executed within a subshell  \r\nArray=(element1 element2 element3) Array initialization  \r\nresult=$(COMMAND)                  Command substitution, new style  \r\n&gt;(COMMAND)                         Process substitution  \r\n&lt;(COMMAND)                         Process substitution<\/pre>\n<p><strong>Double Parentheses<\/strong><\/p>\n<pre>(( var = 78 ))            Integer arithmetic   \r\nvar=$(( 20 + 5 ))         Integer arithmetic, with variable assignment   \r\n(( var++ ))               C-style variable increment   \r\n(( var-- ))               C-style variable decrement   \r\n(( var0 = var1&lt;98?9:21 )) C-style trinary operation<\/pre>\n<p>This might be a bit of a niche subject, but I&#8217;m leaving it here for my own use.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Handy guide to bash brackets, swiped from Stackoverflow. Brackets if [ CONDITION ] Test construct if [[ CONDITION ]] Extended test construct Array[1]=element1 Array initialization [a-z] Range of characters within a Regular Expression Curly Brackets ${variable} Parameter substitution ${!variable} Indirect variable reference { command1; command2; . . . commandN; } Block of code {string1,string2,string3,&#8230;} Brace [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[74],"tags":[],"class_list":["post-882","post","type-post","status-publish","format-standard","hentry","category-geek"],"_links":{"self":[{"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/882","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=882"}],"version-history":[{"count":2,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/882\/revisions"}],"predecessor-version":[{"id":889,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/882\/revisions\/889"}],"wp:attachment":[{"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}