To get the server IP shell script:
| The code is as follows |
Copy Code |
#!/bin/bash Ifconfig | grep ' inet addr: ' | Grep-v ' 127.0.0.1 ' |cut-d:-f2 | awk ' {print '} '
|
Download Whole Station
WGET-MK http://www.111cn.net
Judge the existence of a file
| The code is as follows |
Copy Code |
#!/bin/bash if [!-F/ROOT/LOG.L] Then echo "LOG.L note exist" Fi
|
Common syntax
While statement
| The code is as follows |
Copy Code |
#!/bin/bash echo "Enter passwd" Read passwd While [$passwd!= "Iterse"];d o echo "Sorry try Again" Read passwd Done |
For statement
| The code is as follows |
Copy Code |
#! /bin/bash For i in a b C; Todo echo "$in" Done |
Case statement
| code is as follows |
copy code |
| #!/bin/ SH echo "Enter a number" Read number Case $number in 1) &nb sp; echo "You are 1" ; 2) echo "Yo number is 2" ; *) exit 1 ;; Esac |
If Else elif fi
| The code is as follows |
Copy Code |
#! /bin/sh echo "Is it morning? Please answer yes or No. " Read Yes_or_no If ["$YES _or_no" = "yes"]; Then echo "Good morning!" elif ["$YES _or_no" = "NO"]; Then echo "Good afternoon!" Else echo "Sorry, $YES _or_no not recognized. Enter yes or No. Exit 1 Fi Exit 0 |