Skip to content

Instantly share code, notes, and snippets.

@jintao-zero
Created August 18, 2017 02:41
Show Gist options
  • Save jintao-zero/fa9a40f0340c2072901b960e2f228607 to your computer and use it in GitHub Desktop.
Save jintao-zero/fa9a40f0340c2072901b960e2f228607 to your computer and use it in GitHub Desktop.
bash argument case
#!/bin/sh
if [ $# -lt 1 ]
then
echo $0 opt
echo 'list (list all topic)'
echo 'describe topic (describe topic info)'
echo 'len topic (show topic len)'
fi
case $1 in
list)
./kafka-topics.sh --zookeeper 127.0.0.1:2181 --list
;;
describe)
./kafka-topics.sh --zookeeper 127.0.0.1:2181 --describe --topic $2
;;
len)
./kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list 10.168.37.52:9092 --partitions 0 --topic $2
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment