Skip to content

Instantly share code, notes, and snippets.

@xiazhibin
Last active January 27, 2019 13:52
Show Gist options
  • Save xiazhibin/b2d7b17a90cc613bb100efa28d3c9dc1 to your computer and use it in GitHub Desktop.
Save xiazhibin/b2d7b17a90cc613bb100efa28d3c9dc1 to your computer and use it in GitHub Desktop.
将redis cmd转化为redis协议
#!/bin/bash
while read CMD; do
# each command begins with *{number arguments in command}\r\n
XS=($CMD); printf "*${#XS[@]}\r\n"
# for each argument, we append ${length}\r\n{argument}\r\n
for X in $CMD; do printf "\$${#X}\r\n$X\r\n"; done
done < redis_commands.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment