Bash: [[…]]: the pattern, quoting, …

I was tempted to put the entire pattern in (double) quotes. But that’s not Bash style. You can “certainly” put literal parts in quotes, but regexp parts do not belong in quotes — quotes are good for protecting, amongst other aspects: protecting against interpretation as regular expression. That’s different to usual programming languages. Usually you do sort of put your entire regular expression in “borders” — in Bash you don’t.

This example resp. advice is actually quite wrong (but I am not able to comment there — I have not earned enough reputation on stackoverflow.com yet):


Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.