bjorn.now

October 9, 2025

All I got up to this day (as far as you know)

2 posts on this day

Don’t quote regex patterns in Bash [[ ]] tests, because they’ll match literally.

So the below won’t match because it’s looking for a literal $ in the string, instead of matching at the end of the string:

file="https://example.com/blog-post/index.html"
[[ "$file" =~ "/index.html$" ]] && echo MATCH

But this will:

file="https://example.com/blog-post/index.html"
[[ "$file" =~ /index\.html$ ]] && echo MATCH

Note: [[ ]] is a Bash extension of the test command that supports regexes (among other things). The [ ] is the POSIX standard test (see man test), so [[ ]] features may not work in other shells or in limited shells like ash or sh.

[… more]
til 1 min read #bash, #regex, #shell-scripting

the first (digital) forms signed on the quest of starting my own company, now the waiting begins

scrap Updated