Created
August 29, 2019 01:29
-
-
Save neilhwatson/f87c539acf0fbc56a87c11a59130800c to your computer and use it in GitHub Desktop.
Bash regex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
port='123:567' | |
port_regex="([0-9]+):([0-9]+)" | |
echo what to change ports $port | |
if [[ $port =~ $port_regex ]] | |
then | |
from=${BASH_REMATCH[1]} | |
to=${BASH_REMATCH[2]} | |
echo changing port $from to $to | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment