Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.