Skip to content

Instantly share code, notes, and snippets.

@ejdanderson
Created June 23, 2012 03:08
Show Gist options
  • Save ejdanderson/2976559 to your computer and use it in GitHub Desktop.
Save ejdanderson/2976559 to your computer and use it in GitHub Desktop.
Bash token prompt
#!/bin/bash
if [ -z $1 ]; then
echo "Usage: inputs.sh file.txt"
else
codes=$(grep -o "###.*###" $1)
inputs=$(echo $codes | sed 's/#//g')
for x in $inputs; do
#Check if the variable is empty
if [ "${!x}"z == "z" ]; then
read -rp "$x: " $x
fi
echo ${!x}
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment