Skip to content

Instantly share code, notes, and snippets.

View seancamden's full-sized avatar
🏠
Working from home

Sean Camden seancamden

🏠
Working from home
View GitHub Profile
@JPvRiel
JPvRiel / bash_regex_match_groups.md
Last active October 16, 2023 15:28
Bash regular expression match with groups including example to parse http_proxy environment variable

The newer versions of bash (>= 3.0) include a regex operator =~

Simple example

$ re='t(es)t'
$ [[ "test" =~ $re ]]
$ echo $?
0
$ echo ${BASH_REMATCH[1]}
es