The cut command common parameters: -C Character Character -d delimiter delimiter -f field fields (columns) --output-delimiter output DELIMITER Example: # 12345 echo | cut -c2 2 # echo 12345 | cut -c1,4 14 # 12345 echo | Cut-C2-4 234 # the ifconfig eth0 | grep Mask | Cut -d "" -F12 | Cut -d ":" -f2 # head -1 / etc / the passwd | Cut -d ":". 1 -f , --output-3,4- DELIMITER = "#" 1.case statement (2) case syntax Case "Choice" in "var1") statement ;; "var2") statement ;; "var3") statement ;; * ) statement esac (2) the use of copy from a passage in /etc/init.d/httpd Case "$ 1" in Start) Start ;; STOP) STOP ;; Status) Status -p $ {} $ httpd the PidFile RETVAL = $? ;; restart ) STOP Start ;; *) echo $ "Usage: $ {PROG Start | STOP | restart | condrestart | reload | Status | fullstatus | Use the graceful | Help | configtest}" Exit 1 esac ----------- --------- example: sshd script # / bin / bash! Case "$ 1" in Start) # service sshd start pid = `pidof sshd` IF [the -Z PID $]; the then / usr / sbin / the sshd echo" Starting sshd: [OK] " the else echo" service sshd (pid $ pid) already exists. " Fi ;; STOP) # service sshd stop pid = `pidof sshd` IF [the -z $ pid]; the then echo" service sshd has stopped " the else killall sshd &> / dev / null echo" stop sshd: [OK] " fi ;; restart) # restart pid = `pidof sshd` IF [the -z $ pid]; the then echo" stop sshd: [failure] " / usr / sbin / sshd echo" starting sshd: [OK] " the else echo" stop sshd: [OK ] " /usr/sbin/sshd fi ;; status) # View state pid = `pidof sshd` IF [the -z $ pid]; the then echo" sshd service has been suspended, " the else echo" service sshd (pid $ pid) is running ... " fi ;; *) # If the parameters are not start | stop | restart | time status, the prompt echo" usage: /root/ssh1.sh {start | stop | restart | Status} " esac Example: write a shell script, pass into a parameter (the letter), to determine the size of the incoming letters or lowercase #! / bin / bash Case "$ 1" in [AZ]) echo "capital" ;; [az]) echo "lowercase" ;; *) echo "not the letter" exit 1 esac ----------------------------------- #!/bin/bash if [[ "$ 1" = ~ [AZ]]]; then - ~ symbol matching means echo "uppercase" elif [[ "$. 1" = ~ [AZ]]]; the then echo "lower case" the else echo "is not the letters " fi 2. the SELECT the SELECT expression is an extension to apply a bash, the introduction from ksh. 2.1 Syntax PS3 = "prompt" - to use PS3 to output the message select var in Choice1 Choice2 Choice3 ... do echo "................." DONE 2.2 with select do a selection menu #! / bin / bash PS3 = "Please select the type of phone you're using" the sELECT HUAWEI Xiaomi phone in the iPhone OPPO samsung lenovo meizu do Case "$ phone" in the iPhone) echo "you are using the $ phone" ;; *) echo "you are using Phone $" echo "Android" BREAK ;; esac DONE