select in case문 질문
미해결
리눅스 쉘 스크립트 마스터
#!/bin/bash ##v.2.0 export IP1="0" export IP2="0" export IP3="0" export DATE=$(date +"%F") PS3="Select the option " select char in "1, Check IP" "2, IP List" "3, Exit" #"4"# do case $char in 1*) read -p "Enter IP xxx.xxx.xxx. > " -t 20 IP1 read -p "Enter start IP xxx > " -t 20 IP2 read -p "Enter last IP xxx > " -t 20 IP3 echo -e "\033[32;1m"IP Checking!"\033[0m" while [[ $IP2 -lt $IP3 ]]; do ping -c 1 -w 1 $IP1$IP2 > /dev/null if [[ $? == 0 ]]; then echo $IP1$IP2 is In-use. >> /tmp/ip_list_$DATE ; else echo $IP1$IP2 is Dead or Available. >> /tmp/ip_list_$DATE ; fi IP2=$(($IP2+1)) done echo -e "\033[31;1m"IP Check well done! please verify IP"\033[0m" ;; 2*) grep -q Avail* 2> /dev/null < /tmp/ip_list_$DATE if [[ $? == 0 ]]; then grep -r --color=always Available /tmp/ip_list_$DATE | sort -u else echo -e "\033[31;3m"There is no available IP"\033[0m" fi ;; 3*) echo "Good bye"; exit 0 ;; #4*) echo "You choose not yet menu it will be add section coming soon asap" ;; *) echo "!!Error select correctly number!!" esac done 위와 같이 실행시 결과 값 [root@hlldvc ddrec]# ./ipcheck.sh 1) 1, Check IP 2) 2, IP List 3) 3, Exit Select the option 이와 같이 1)1, 숫자가 중복이 되는 현상이 발생합니다. 미관상 좋지 않아보여 중복 제거를 위해 여러 방법을 시도해 보는중이지만 잘 되지 않습니다. 혹시 다른 방법이 있을까요..?
- 쉘스크립트
- linux
- shell-script





