Skip to content

Instantly share code, notes, and snippets.

@tsabat
Created September 7, 2013 19:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsabat/6478597 to your computer and use it in GitHub Desktop.
Save tsabat/6478597 to your computer and use it in GitHub Desktop.
a unique list of all connected redis clients
redis-cli client list | awk '{print $1}' | sed s/addr=//g | sed s/:.*//g | uniq
@mabushey
Copy link

  1. Use awk '{print $2}' - id was introduced in Redis 2.8.12 and is now $1
  2. uniq only works when the data is already sorted, use sort -u

If you want a count of unique clients, use: redis-cli CLIENT LIST | awk '{print $2}' | sed s/:.*//g | sort -u | wc -l

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment