shell编程如何迅速枚举

如题所述

while getopts ":l:c:" opt;do case $opt in l) dict_length=$OPTARG;; c) dict_char=$OPTARG;; \?) echo 'Usage: dict.sh -l dict_length -c "dict_char"' exit 1;; esacdoneshift $(($OPTIND - 1)) #根据字典的长度产生单词,象这样:${pi}${pi-1}.....${p1}key_str(){ for((i=$1;i!=0;i--));do pswd=$pswd\${p$i} done} #用字典替换${pi}char_sub(){ idx=$1 for char in $dict_char;do eval p${idx}=$char if [ $idx -gt 1 ];then ((--idx)) char_sub $idx ((++idx)) continue fi eval echo $pswd done}
温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜