1, file descriptor -e Determine whether the object exists
-d Determine whether the object exists and is a directory
-f Determine whether the object exists, and it is a regular file
-L Determine
Tag: shell
Strive_tan shell programming actual combat 2-distribution system
1. Expect applications
1) Transfer files
2) Execute commands remotely, no interaction, no need to enter a password
3) The core of the online shell script (tool) is expect, which i
Shell Training Day8 8.22
while loop
? Syntax while condition; do…; done
? Case 1
#!/bin/bash
while :
do
load=w|head -1|awk -F’load average: ”{print $2}’|cut -d. -f1
if [$load -gt 10 ]
then
top|mail -s “load is high:
Shell script prints parallelogram, diamond
Shell script printing parallelograms #!/bin/ bash
for ((i=1;i<= 9;i++))
do
for ((j=9;j>=i;j- -))
do
echo -n ” ”
done
for ((j=2;j<= i;j++)) do echo -n "*" done for ((j=1;j<
Shell for loop demo
test.sh
#!/bin/bash
for skill in Ada Coffe Action Java; do
echo “I am good at ${skill}Script”
done Output
bogon:Desktop macname$ ./test.sh
I am good at AdaScript
I am good at Cof
Shell Programming: Use scripts to achieve NGINX’s guardianship restart
nginx_daemon.sh #!/bin/bash
#
this_pid=$$
while true
do
ps -ef | grep nginx | grep -v grep | grep -v $ this_pid &> /dev/null
if [$? -eq 0 ];then
echo ” nginx is ok”
sleep 3
else
SHELL script programming common sense
common sense of Shell script programming span> (These are often used frequently, but all kinds of materials on the Internet are vague things, personally think they are more useful)
s b sock
Shell script is program monitoring
Monitor the program of this machine and send alarm emails abnormally
#!/bin/bash
# Native IP
HOST=‘59.110.69.217’
# Mail service address
URL=‘http://101.201.150.205:9527’
# Mail receiving
Shell single quotes and double quotes
#!/bin/bash
a=23
echo ‘$a’
echo “$a”
your_name=’runoob’
str=”Hello, I know you are \”$your_name\ “! \n”
echo -e $str
echo $str Output
bogon:Desktop macname$ ./test.sh
$a
23
Hello
Shell script for, while, case statement details and case
################for loop statement structure#############
When using for loop statement, you need Specify a variable and a list of possible values, and repeat the same command sequence for each dif