a,[] single and double bracketsBasic elements:[] Two symbols should be separated by a space aroundThere is a space between the internal operator and the action variable: such as ["a" = "B"]String comparisons in,> \ [] in the string or ${}
There are 3 ways to execute the shell script:
Bash xxxxx.sh or SH xxxxx.sh (recommended)
Path/xxxxx.sh or./xxxxx.sh (Execute script under current path)
SOURCE xxxxx.sh or. Xxxxx.sh (there is a space behind the dot.) This way you can put
$* is a collection of all incoming parameters for the function (script) where this line command is locatedSimilar to [email protected] without quotes, no differenceThe difference is when the "" is amplified."$*" is treated as a string"[Email
before starting the code, let's take a look at what a shell is. Shell English is also called the shell layer. In a computer, "system" software that "provides user interface", usually refers to the command parser of the command line interface. In
#for循环#格式#for variable in list#do# Command1# Command2# ...#doneA sequence of #列表是一组值 (numbers, strings, etc.), each separated by a space. Once per loop, assign the next value of the list to the variable#in list is optional, if it is not used, the
1. Requirements backgroundFor large companies, there must be a site or configuration file updates from time to time, and the use of the machine is certainly a lot of units, less than a few, more than dozens of or even hundreds of sets. Therefore,
The following is an explanation under the bash environment.One, single parenthesis ()Two, double parenthesis (())Can be used as a numerical condition or as a numerical operation (approximate to let command)Like the C language syntax, supports
& placed after the startup parameter to set this process as a background process
By default, the process is the foreground process, then the shell is occupied, we can not do other operations, for those who do not interact with the process, many
The order in which environment variables are loaded after Linux startup is: ETC/PROFILE→/ETC/PROFILE.D/*.SH→~/.BASH_PROFILE→~/.BASHRC→[/ETC/BASHRC]To change the color of the shell font after a user logs in, add PS1 content to the ~/.BASHRC, and the
Http://blog.chinaunix.net/uid/21411227/cid-63616-list-1.html1. Determine the file type –b Returns True when file exists and is block -C Returns True when file exists and is a character -D returns True when pathname exists and is a directory -E
Position parameters can be usedShiftcommand to move left. Like whatShift 3said the original $4 now become $ $ , the original $ $ now becomes $ $, etc., the original $, $, $ discarded, don't move. The shift command with no parameters is
Sometimes we use a function often, it is very troublesome to assign a value in each script, this time we can write the function that we use frequently in the form of function library.A very simple little example: do we need to know which version of
One, parenthesis, round brackets () 1, single parenthesis () ① command group. The commands in parentheses will be executed in a new sub-shell sequence, so the variables in parentheses cannot be used by the rest of the script. Multiple commands in
These days need to do Linux TCP port check script, found that netstat, NC command, although good, but not intuitive, and the port is a bit more trouble to check, hands-on learning to do two scripts. One is to check the port condition in the form of
Using the remote shell tool SSH login to the Linux host, the user name after the return to the card, 10 seconds after the prompt to enter the password.Use Wireshark to catch the whole process packageBecause SSH is an encrypted protocol, it is not
Learning Shell The script experience
Shell script Run Environment:Shell script, is to put multiple commands, organized into a file, to implement a series of actions, convenient execution of a file.
Shell scripts are primarily used in
In the shell command terminal. CTRL + N is equivalent to the direction down direction key, ctrl+p equivalent to the direction upward direction key.In the command terminal through them or the direction of the key to achieve a high-speed search
Sed is a stream editor, which is a very useful tool in text processing and can be used perfectly in conjunction with regular expressions. When processing, the currently processed rows are stored in a temporary buffer called pattern space, followed
IntroductionVariables are an essential part of Shell scripting, and using variables in scripts does not need to be declared in advance. Each variable in bash is a string, so whenever a variable is assigned a value, whether or not the quotation marks
Restricting the shell, like Rsh and Scponly, allows the system administrator to restrict what Linux users can do, and you can create users that will be allowed to copy files through the SCP, but will not be allowed to log on to the system's command
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service