Skip to content

Instantly share code, notes, and snippets.

@FanchenBao
Created January 24, 2024 18:30
Show Gist options
  • Save FanchenBao/5bd7eedc4889032df6c62c95062d1ae8 to your computer and use it in GitHub Desktop.
Save FanchenBao/5bd7eedc4889032df6c62c95062d1ae8 to your computer and use it in GitHub Desktop.
ggrep recipe
# ggrep is the GNU grep. On macOS, it is installed via `brew install grep`
# Using perl regex for lookahead and lookbehind
# This example greps the EXACT match between quotation marks
aws lambda publish-version --function-name foo --profile bar | ggrep -Po '(?<=")\d+(?=")'
# This example counts the number of occurrences of "prod" that is wedged bewteen string literals
# '"Name": "' and '"'
aws lambda list-aliases --function-name foo --profile bar | ggrep -Pc '(?<="Name":\s")prod(?=")'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment