Last active
June 14, 2018 12:32
-
-
Save mlsaito/e9943293ce0b616e53d9aad16a473e67 to your computer and use it in GitHub Desktop.
Execute Redis commands via Bash
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
#!/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