Tag:Shell Scripting
-
Judgment statement of shell script programming
1、 Single branch if statement Format: if judgment condition; then statement1 statement2 … fi 2、 Double branch if statement Format: if judgment condition; then statement1 statement2 … else statementN … fi Use a previously used script to illustrate this structure. 3、 Multi branch if statement Format: if judgment condition 1; then statement1 … Elif judgment […]
-
Circular statements in Shell Scripting
It is common to execute a series of commands repeatedly when running a script. At this time, we need to use circular statements to achieve this purpose. 1、 For command Format: for variable in list; do Circulatory body done The for command iterates through each value in the list and exits the loop after the […]
-
Shell Scripting array
An array is a set of elements of the same data type arranged in a certain order. It is a set that names a limited number of variables of the same type, and then distinguishes their variables with numbers. This name is called the array name, and the numbers are called subscripts. The variables that […]
-
Eight reliable suggestions for Shell Scripting
These eight suggestions come from the experience and lessons of keyers in writing shell scripts over the past few years. As a matter of fact, I started to write more than these articles. Later, I thought about it again and again, removed some irrelevant ones, and finally left eight. It’s no exaggeration to say that […]
-
How to write and run Linux shell (. SH) scripts
Write your first shell script Write. Sh file in GEDIT and save it as a.sh. code: #! /bin/bash # employ bash shell player1=xiaoming # define a player1 player2=ken echo “Game start! $player1 $player2” # echo is used to printf in terminal Call the script at the terminal, locate the directory, and then enter: bash a.sh […]
-
The Method of Starting and Stopping Tomcat Service by Writing Shell Script in Linux Environment
Step 1: Enter the console as an administrator, and create a new shell script in the specified directory. I’m going to call it tomcat.sh. Step 2: Write shell scripts #!/bin/bash tomcat_home=/usr/tomcat/apache-tomcat-8.0.48 SHUTDOWN=$tomcat_home/bin/shutdown.sh STARTTOMCAT=$tomcat_home/bin/startup.sh case $1 in start) Echo “Start $tomcat_home” $STARTTOMCAT ;; stop) Echo “Close $tomcat_home” $SHUTDOWN pidlist=`ps -ef |grep tomcat |grep -v “grep”|awk ‘{print […]