Last active
July 13, 2020 20:36
-
-
Save GavinRay97/fcd2e7bb7dce9201fadec134a3348fc4 to your computer and use it in GitHub Desktop.
Bash Regex with capture groups
This file contains 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 | |
# VERSION NAME SOURCE STATUS DATABASE STATUS | |
# 1594317652188 - Not Present Present | |
# 1594317688377 - Not Present Present | |
# 1594320512973 - Not Present Present | |
# 1594320556497 - Not Present Present | |
function scan_entries_for_not_present() { | |
# timestamp name source status database status | |
regex="([[:digit:]]+)\s+(\w+|-)\s+(Present|Not Present)\s+(Present|Not Present)" | |
while IFS= read -r line; do | |
if [[ "$line" =~ $regex ]]; then | |
for group in "${BASH_REMATCH[@]}"; do | |
printf "%s\n" "$group" | |
done | |
else | |
printf "No match \n" | |
fi | |
done | |
} | |
hasura migrate status | scan_entries_for_not_present |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment