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}