Skip to content

Instantly share code, notes, and snippets.

@mlsaito
Last active June 14, 2018 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlsaito/e9943293ce0b616e53d9aad16a473e67 to your computer and use it in GitHub Desktop.
Save mlsaito/e9943293ce0b616e53d9aad16a473e67 to your computer and use it in GitHub Desktop.
Execute Redis commands via Bash
#!/usr/bin/env bash
#! This will output info to `users_info.csv`
echo "Getting info from Redis. . ."
redis-cli ping
for i in {1..29885}; do
#! as of 2018, we can use this: EMAIL=$(command) instead
#! Reference: https://stackoverflow.com/questions/4651437/how-to-set-a-variable-to-the-output-of-a-command-in-bash
EMAIL=`redis-cli get "u:$i:mail"`
PLAN=`redis-cli get "u:$i:current_plan"`
echo "$i, $EMAIL, $PLAN"
echo "$i, $EMAIL, $PLAN" >> users_info.csv
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment