Last active
September 17, 2020 09:51
-
-
Save olivertappin/d2e7682bfd118ac64127dad6aaf3645c to your computer and use it in GitHub Desktop.
Extract a string from a commit message between two square brackets
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
# Example with a space after the colon | |
echo "bc3977f Some beautiful long commit message [skip: verification]" | sed -En 's/.*\[skip\:(.*|\ .*)\]/\1/p' | awk '{$1=$1;print}' | |
verification | |
# Example with no space after the colon | |
echo "bc3977f Some beautiful long commit message [skip: verification]" | sed -En 's/.*\[skip\:(.*|\ .*)\]/\1/p' | awk '{$1=$1;print}' | |
verification | |
# Working example from the last commit message | |
git log -1 --oneline | sed -En 's/.*\[skip\:(.*|\ .*)\]/\1/p' | awk '{$1=$1;print}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment