Stripping Environment File Content from the CLI
Author: Anda Toshiki
Published: 2025-10-04
Updated: Unknown
Words: 109
Reading: 1 min
bash
sed -E 's/^([A-Za-z_][A-Za-z0-9_]*)=.*/\\1=/; /^#|^$/!s/ //g' .env | pbcopyExplanation
sed -E→ enable extended regex.^([A-Za-z_][A-Za-z0-9_]*)=.*→ matches variable assignments; replaces them with just the variable name (\\1=).^#|^$→ comments or empty lines → left as-is.pbcopy→ pipes the final output to your macOS clipboard.
