Created
March 11, 2015 08:37
-
-
Save rndD/b831b53314db8c1c07c8 to your computer and use it in GitHub Desktop.
print shortest env variable by key (work only in bash, not sh)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in `env`; do | |
key=${i%=*} | |
[[ -z $short_env ]] && short_env=$key; | |
[[ ${#key} -lt ${#short_env} ]] && short_env=$key; | |
done | |
echo "Shortest env variable: $short_env" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment