Skip to content

Instantly share code, notes, and snippets.

@neilhwatson
Created August 29, 2019 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilhwatson/f87c539acf0fbc56a87c11a59130800c to your computer and use it in GitHub Desktop.
Save neilhwatson/f87c539acf0fbc56a87c11a59130800c to your computer and use it in GitHub Desktop.
Bash regex
#!/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