Created
October 11, 2016 14:11
-
-
Save JohnMarkT/737c8cb437144959f8a27dd30e54913d to your computer and use it in GitHub Desktop.
Shell script to convert environment variables list file to single line to use on the command line
This file contains hidden or 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
#!/bin/sh | |
if [ $# -lt 1 ]; then | |
echo "usage: loadenv filename" | |
exit 2 | |
fi | |
HASH="#" | |
for ENV_FILE in "$@"; do | |
#echo "file: $ENV_FILE" | |
if [ -f $ENV_FILE ]; then | |
#echo "loading: $ENV_FILE" | |
while read line || [ -n "$line" ]; do | |
if [[ "$line" == *=* ]] && [[ "$line" != ${HASH}* ]]; then | |
LOAD_ENV=$LOAD_ENV" "$line | |
fi | |
done < "$ENV_FILE" | |
fi | |
done | |
echo $LOAD_ENV |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment