Skip to content

Instantly share code, notes, and snippets.

@dginhoux
Created October 29, 2022 18:28
Show Gist options
  • Save dginhoux/56f6a85db748895a4766006e217700a5 to your computer and use it in GitHub Desktop.
Save dginhoux/56f6a85db748895a4766006e217700a5 to your computer and use it in GitHub Desktop.
### bash split
${var#*SubStr} # will drop begin of string up to first occur of `SubStr`
${var##*SubStr} # will drop begin of string up to last occur of `SubStr`
${var%SubStr*} # will drop part of string from last occur of `SubStr` to the end
${var%%SubStr*} # will drop part of string from first occur of `SubStr` to the end
string="}
echo $string | cut -d';' -f1 # output is 1
echo $string | cut -d';' -f2 # output is 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment