Bash

Print Environment Variables Matching Pattern

admin by @admin ADMIN
1d ago
May 31, 2026
Public
0 0 up · 0 down Sign in to vote
Quick audit of env vars by prefix — useful when debugging containerized apps that read from `STRIPE_*`, `DB_*`, etc.
Bash
Raw
# All env vars whose name starts with STRIPE_
env | grep '^STRIPE_'

# Sorted, aligned for readability
env | grep '^STRIPE_' | sort | awk -F= '{printf "%-30s %s\n", $1, $2}'

# Masked (don't print secrets — show only first/last few chars)
env | grep -E '^(DB_PASS|SECRET|STRIPE_SECRET)' | \
    awk -F= '{printf "%-25s %s***%s\n", $1, substr($2,1,4), substr($2,length($2)-3)}'

# Print all of YOUR custom vars (NOT system PATH/HOME/etc)
env | grep -vE '^(PATH|HOME|PWD|SHELL|USER|TERM|LANG|LC_)' | sort
Tags

Save your own code snippets

Create a free account and build your private vault. Share publicly whenever you want.