Skip to content

Instantly share code, notes, and snippets.

@bashkirtsevich
Last active February 9, 2022 21:06
Show Gist options
  • Save bashkirtsevich/1e2b843b566b21ec95c8469849420c1a to your computer and use it in GitHub Desktop.
Save bashkirtsevich/1e2b843b566b21ec95c8469849420c1a to your computer and use it in GitHub Desktop.
Enum os envs values by pattern
#!/bin/sh
vals=""
while read -r line ; do
val=$(echo $line | cut -d= -f2)
vals+="$val "
done < <(env | grep ENV)
for val in $vals ; do
echo "Found val $val"
done
# bad solutions:
env | grep ENV | while read -r it ; do echo $(echo $it | cut -d= -f2) ; done;
env | grep ENV | while read -r it ;
do
value=$(echo $it | cut -d= -f2)
echo $value
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment