In some cases, such as Oracle, you must switch to the specified user to restart Oracle.Each time the manual operation is more troublesome, you can write a script.The function of automatically entering password, need to use expectInstall firstYum
Directly on the script,Use $ (()) and $[] for numeric calculationsNumerical comparison:N1-eq n2 Check if N1 equals N2 n1-le n2 check N1 is less than or equal to N2N1-ge n2 Check if N1 is greater than or equal to N2 n1-lt n2 check N1 is less than N2N1
Some of the more functional requirements are relatively simple to consider using the shell script to write, so as to facilitate fast and stable1. Read the file value, open and close some programs according to the file value 1 or.A. While:DoDoneis an
There are three types of conditions that are commonly tested in bashConditional test expression: [expression] [[expression]]First: Integer test:-eq tests whether two integers are equal, such as [$A-eq $B]-ne test two integers in different sizes-GT
$ represents the current process when using the Echo $$ is the PID that will output the current shell1 Echo $$
List of special variables
variables
meaning
$
File name of the current script
Experiment Server Two:192.168.77.189192.168.77.190
Server-free key login settings:[email protected]_168_77_189 ~]# Ssh-keygenGenerating public/private RSA key pair.Enter file in which to save the key (/ROOT/.SSH/ID_RSA):Enter passphrase (empty for
1. Declaration of variablesName= "Blacksonny" Note://variable definition does not add $, the variable and equal sign cannot have spaces betweenVariable naming rules:
The first character must be a letter (a-z,a-z).
You can use an
Code: Script_name parameter1 parameter2 Parameter3 ...It's easy to guess that the $ A is the shell script name (path) itself, and $ $ is the first argument, and so on .... you have to pay attention to the role of IFS, that is, if IFS is quoting,
If there are some special characters in the shell, you need to replace them, you can do command substitution, variable substitution, escape substitution1. Substitution of escape charactersThe shell contains the following transfer characters\a Bell
Start your own shell script practice today, just as the company has too servers, to time the data of the CP is monthly:Consider: First look for the law, found all placed in the/opt/www/aaa/there are a lot of 2 level and 3 levels of directories and
In the previous blog, the implementation of the automated test program was written, and now the developer needs to know the running state of the process that was tested (in this case, the main process running on Linux) before the exception exited,
Syntax for the FOR loop:1. For variable in value 1 value 2 value 3 ....DoProgramDoneFor example: The following script will print 4 times respectively the value of morning noon afternoon evening1 #!/bin/bash2#打印时间 3#Author mrfeng45 for-time in
1. Single-branch if condition statement1 if [conditional judgment type]; Then 2 program 3fi4 or 5if [conditional judgment]6 then 7 program 8fiPrecautions:The 1.if statement uses the fi end, and the general language uses curly
Typically, when you write a shell script, you'll find that the same piece of code is used in multiple places. It doesn't matter if it's just a small piece of code. But it's hard to rewrite chunks of code multiple times in a shell script. The bash
Regular expressions are primarily a grammar rule used to describe character permutations and matching patterns. It is mainly used for the pattern segmentation, matching, finding and substitution of strings, the main purpose is to match.Wildcard
Need to deploy the server itself, so after the application of space, you need to install Linux itself, install Apache, etc., so download the compressed file needs to run. On the internet to find some decompression command wrong, especially try the
Array:A collection of a bunch of variables.Statement:Declare-a ArraynnameEach of these variables is Arrayname[index]Index starts from 0.Assignment value:Arrayname[index] = VALUEArrayname = (VALUE1 VALUE2 ...)Arrayname = ([index1]=value1
/Etc/profile and/etc/bashrc, interactive and non-interactive, the difference between login and non-login shell, bashrcnon-loginThe online memcached crashes again and still does not get the core file. Check the cause and find that the script for
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.