Skip to content

Instantly share code, notes, and snippets.

@caruccio
Last active October 2, 2023 15:00
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 caruccio/0b08ba0667ea2e171895412dc5c14a36 to your computer and use it in GitHub Desktop.
Save caruccio/0b08ba0667ea2e171895412dc5c14a36 to your computer and use it in GitHub Desktop.
Bash regex conditionals

In bash you can use [[ pattern =~ regex ]] to match on a conditional:

if [[ "hello world" =~ ^hell ]]; then
  echo Match
else
  echo No match
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment