Skip to content

Instantly share code, notes, and snippets.

@lopes
Last active August 7, 2024 15:00
Show Gist options
  • Save lopes/d7b0eada6582b730abf1006b940cbff9 to your computer and use it in GitHub Desktop.
Save lopes/d7b0eada6582b730abf1006b940cbff9 to your computer and use it in GitHub Desktop.
Shell snippets using common Unix tools. #shell #shellscript #unix #linux #bsd
# Lists all commits made by author and pretty print them
git --no-pager log --pretty=tformat:"%ci: %H: %cn: %s" [email protected]
# Lists all files staged in a commit. Useful to investigate changes between versions
git diff-tree --no-commit-id -r --name-only 65f4a74f72c816db89fc5bd8d71bbdfbe526e2f7
# Counts the number of items inside the array alerts within reply.
jq '.reply.alerts | length' cortex-alerts.json
# Gets Tesouro Direto bonds and filters out only IPCA+ 2025 from them.
curl -s <https://www.tesourodireto.com.br/json/br/com/b3/tesourodireto/service/api/treasurybondsinfo.json> | jq '.response.TrsrBdTradgList[] | select(.TrsrBd.nm | test("IPCA+.*2035"; "i"))'
# Filters only the Technique and Tactic from MITRE ATT&CK's mapping.
jq '.techniques[] | .techniqueID, .tactic' guardduty-navigator.json
# From all Slack user groups, filters the ones that match the regex and amongst them, shows only name, description, and handle.
jq '.usergroups[] | select(.handle | test(".*on-?call")) | .name, .description, .handle' slack-user-groups-20230116.json
# Figures start with [!...](...)
find ./content -type f -name "*.md" -exec grep -l "^.\\[.*\\]\\(.*\\)" {} \\;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment