1. According to IP output card name
#!/bin/bash ip addr|grep ^[0-9]|awk -F '[: ]+' '{print $2}'>/tmp/eth.list ## use an infinite loop to prompt the user to enter the correct name of the card, enter the correct name of the card out of the cycle of death the while: do echo "at The Network Card CAT IS` /tmp/eth.list | xargs` "# multiple lines as a single line read -p "enter the card name:" the X- IF [the -z "the X-$"] the then echo "Please enter a name card" the Continue fi ! IF grep -qw "the X-$" /tmp/eth.list the then echo "input NIC name does not exist, please enter the correct network adapter name " the Continue the else BREAK fi DONE ## a case where an IP network card, ip write variables # ip = `ip addr show dev eth0 | grep -w" inet "| awk '{print $ 2}' | awk -F / '{print $ 1}'` #echo "The $ x ip is $ ip" A network adapter ## of a plurality of IP, IP written to the file NET_IP () { IP addr Show dev eth0 | grep -w "inet" | awk 'Print $ {2}' | awk -F / '{}. 1 Print $' > /tmp/$1.txt n-WC = `-l /tmp/$1.txt|awk '{}. 1 Print $'` IF [$ n--eq 0] the then echo "The no. 1 $ the IP" the else echo "The IP $. 1 IS: " CAT /tmp/$1.txt Fi } NET_IP $ X |
2. List the directory contents
3. Download the file
#!/bin/bash IF [$ # -ne 2] the then echo "You must enter two parameters, the first parameter for the site, and the second parameter is the directory" Exit 1 fi if [ ! -d $2 ] then while : do echo "$2目录不存在,是否创建该目录?(y|n)" read c case $c in y|Y) mkdir -p $2 break ;; n|N) exit 51 ;; *) echo "请输入y或者n" continue ;; esac done else cd $2 wget $1 if [ $? -eq 0 ] then exit 0 else echo "下载失败" exit 52 fi fi |
4. 猜数字
5.