{"id":9482,"date":"2018-03-01T13:33:42","date_gmt":"2018-03-01T12:33:42","guid":{"rendered":"http:\/\/www.b.shuttle.de\/hayek\/hayek\/jochen\/wp\/blog-en\/?p=9482"},"modified":"2018-03-01T13:33:42","modified_gmt":"2018-03-01T12:33:42","slug":"bash-double-square-bracket-the-pattern-quoting","status":"publish","type":"post","link":"https:\/\/wp.jochen.hayek.name\/blog-en\/2018\/03\/01\/bash-double-square-bracket-the-pattern-quoting\/","title":{"rendered":"Bash:\u00a0[[\u2026]]: the pattern, quoting, &#8230;"},"content":{"rendered":"<ul>\n<li><a href=\"https:\/\/www.gnu.org\/software\/bash\/manual\/html_node\/Conditional-Constructs.html\">https:\/\/www.gnu.org\/software\/bash\/manual\/html_node\/Conditional-Constructs.html<\/a>\u00a0&#8212; look for the very helpful\u00a0<em>xxx.txt<\/em> example!<\/li>\n<\/ul>\n<p>I was tempted to put the entire pattern in (double) quotes. But that&#8217;s not Bash style. You can &#8220;certainly&#8221; put literal parts in quotes, but regexp parts do not belong in quotes &#8212; quotes are good for protecting, amongst other aspects: protecting against interpretation as regular expression. That&#8217;s different to usual programming languages. Usually you do sort of put your entire regular expression in &#8220;<em>borders<\/em>&#8221; &#8212; in Bash you don&#8217;t.<\/p>\n<p>This example resp. advice is actually quite wrong (but I am not able to comment there &#8212; I have not earned enough reputation on stackoverflow.com yet):<\/p>\n<ul>\n<li><a href=\"https:\/\/stackoverflow.com\/a\/13542845\/3119172\">https:\/\/stackoverflow.com\/a\/13542845\/3119172<\/a>\u00a0&#8211; the pattern shown there must not be put in quotes<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.gnu.org\/software\/bash\/manual\/html_node\/Conditional-Constructs.html\u00a0&#8212; look for the very helpful\u00a0xxx.txt example! I was tempted to put the entire pattern in (double) quotes. But that&#8217;s not Bash style. You can &#8220;certainly&#8221; put literal parts in quotes, but regexp parts do not belong in quotes &#8212; quotes are good for protecting, amongst other aspects: protecting against interpretation as regular expression. That&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_share_on_mastodon":"0"},"categories":[493,636],"tags":[],"class_list":["post-9482","post","type-post","status-publish","format-standard","hentry","category-regular-expressions","category-the-shell-programming-language"],"share_on_mastodon":{"url":"","error":""},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paO0kP-2sW","jetpack_likes_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/9482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/comments?post=9482"}],"version-history":[{"count":0,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/9482\/revisions"}],"wp:attachment":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/media?parent=9482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/categories?post=9482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/tags?post=9482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}