{"id":2153,"date":"2015-05-12T11:39:58","date_gmt":"2015-05-12T11:39:58","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=2153"},"modified":"2015-05-12T11:39:58","modified_gmt":"2015-05-12T11:39:58","slug":"bash-variable-expansion-formats","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=2153","title":{"rendered":"BASH-Variable Expansion Formats"},"content":{"rendered":"<h4>Variable Expansion Formats<\/h4>\n<table border=\"2\" cellspacing=\"2\" cellpadding=\"2\">\n<thead><\/thead>\n<tbody>\n<tr valign=\"TOP\">\n<td>${#<i>variable<\/i>}<\/td>\n<td>length of\u00a0<i>variable<\/i><\/td>\n<\/tr>\n<tr valign=\"TOP\">\n<td>${<i>variable<\/i><b>:\u2013<\/b><i>word<\/i>}<\/td>\n<td>value of\u00a0<i>variable<\/i>\u00a0if set and not null, else print\u00a0<i>word<\/i><\/td>\n<\/tr>\n<tr valign=\"TOP\">\n<td>${<i>variable<\/i><b>:<\/b>=\u00a0<i>word<\/i>}<\/td>\n<td>value of\u00a0<i>variable<\/i>\u00a0if set and not null, else\u00a0\u00a0<i>variable<\/i>\u00a0is set to\u00a0<i>word<\/i>, then expanded<\/td>\n<\/tr>\n<tr valign=\"TOP\">\n<td>${<i>variable<\/i><b>:<\/b>+<i>word<\/i>}<\/td>\n<td>value of\u00a0<i>word<\/i>\u00a0if\u00a0<i>variable<\/i>\u00a0is set and not null, else nothing is substituted<\/td>\n<\/tr>\n<tr valign=\"TOP\">\n<td>${<i>variable<\/i><b>:<\/b>?}<\/td>\n<td>value of\u00a0<i>variable<\/i>\u00a0if set and not null, else print &#8216;<i>variable<\/i><b>: parameter null or not set<\/b>&#8216;<\/td>\n<\/tr>\n<tr valign=\"TOP\">\n<td>${<i>variable<\/i><b>:<\/b>?<i>word<\/i>}<\/td>\n<td>value of\u00a0<i>variable<\/i>\u00a0if set and not null, else print value of\u00a0<i>word<\/i>\u00a0and exit<\/td>\n<\/tr>\n<tr valign=\"TOP\">\n<td>${<i>variable<\/i>\u00a0#<i>pattern<\/i>}<\/td>\n<td>value of\u00a0<i>variable<\/i>\u00a0without the smallest beginning portion that matches\u00a0<i>pattern<\/i><\/td>\n<\/tr>\n<tr valign=\"TOP\">\n<td>${<i>variable<\/i>\u00a0##<i>pattern<\/i>}<\/td>\n<td>value of\u00a0<i>variable<\/i>\u00a0without the largest beginning portion that matches\u00a0<i>pattern<\/i><\/td>\n<\/tr>\n<tr valign=\"TOP\">\n<td>${<i>variable<\/i>%<i>pattern<\/i>}<\/td>\n<td>value of\u00a0<i>variable<\/i>\u00a0without the smallest ending portion that matches\u00a0<i>pattern<\/i><\/td>\n<\/tr>\n<tr valign=\"TOP\">\n<td>${<i>variable<\/i>%%<i>pattern<\/i>}<\/td>\n<td>value of\u00a0<i>variable<\/i>\u00a0without the largest ending portion that matches\u00a0<i>pattern<\/i><\/td>\n<\/tr>\n<tr valign=\"TOP\">\n<td>${<i>variable<\/i><b>\/\/<\/b><i>pattern1<\/i><b>\/<\/b><i>pattern2<\/i>}<\/td>\n<td>replace all occurrences of\u00a0<i>pattern1<\/i>\u00a0with\u00a0<i>pattern2<\/i>\u00a0in variable<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Variable Expansion Formats ${#variable} length of\u00a0variable ${variable:\u2013word} value of\u00a0variable\u00a0if set and not null, else print\u00a0word ${variable:=\u00a0word} value of\u00a0variable\u00a0if set and not null, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2153","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\/2153","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=2153"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2153\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}