1. ExercisesDesign a script that monitors the surviving state of a remote host (assuming the IP address is 110.110.110.114) and sends a message to yourself when it finds an outage.Tips:
You can use the ping command:
ping -c 10 110.11
Hello everyone, I am the lone cloud twilight rain, brought to you today is the "Linux shell script several circular statements to create the user's method"Add USER1~USER20 UserFor loop:#!/bin/bashfor i in {1..20}douseradd User$iecho ' user$i Users
0. IntroductionPrepare to open a new pit and update a shell practice every day. Because shell scripts belong to the kind of skills that are unfamiliar or even forgotten when you're not practicing, I can only keep on practicing in order to resist the
Shell Common Regular ExpressionsCommon Regular expression ^ # line Header locates $ # end of row. # match any character except line break * # match 0 or more repeating characters + # Repeat once or more? # repeat 0
In order to automate the receipt of file backup information from the server, the MUTT+MSMTP is used to send e-mail in the shell environment, which is an easy and efficient way to complete operations.Download MSMTPwget
Shell IntroductionDuring the development process, the Linux system is frequently contacted and used, and the shell is a bridge for our users to use Linux, and is a program written in the C language. The shell is a command language, as well as a
1. Logical operators;Logical operator Instances:A=Tenb= -if[$a! =$b]then Echo"$a! = $b: A! = b"ElseEcho"$a! = $b: a = b"fiif[$a-lt --A $b-GT the]then Echo"$a less than 100 and $b greater than 15: Returns True"ElseEcho"$a less than 100 and $b greater
This article: Determine whether the user input parameter is a numberHow is the calculation done in the shell?
Way One
[[email protected] scripts]# echo $((1+2)) 3
Way Two
Note: When using the method two, the requirements
$ A This is the path to the script file itself (relative path)If there is an execution script file under the current directory, you cannot write an absolute path for execution.$# this variable to record the number of input parameters6 is the number
1. Arithmetic operator: Native bash does not support simple math operations, but can be implemented with other commands, such as awk and expr,expr most commonly usedExpr is an expression evaluation tool that uses it to perform the evaluation of an
I. Condition selection, judgment (if, case)1.1 If statement usage and examplesWhen we encounter the need to judge in the script, we can use the IF statement to implement. The specific syntax is as follows:Single Branchif judgment condition;
Linux Shell functions
Write in front: function, this word in just the beginning of the classmate looks very tall, in fact, the shell inside the function is very simple, function is actually to reduce the amount of code, so this space may be
In Linux has been learning for one months, today to write a small script, wrote three different, although simple, but you can see, I wrote the script is ping3 times to see if the host is alive!The first one is ~ ~ for~~ loop because I knocked it
Exercise 1:Formatted outputRequirements: Enter a string of random numbers and then output by thousand. for example, the input number string is "123456789", the output is 123,456,789#/bin/bash# date:2018 March 15 read-p "Please input a long number:"
Users of the Linux server should know that when Linux is in use, the available memory will slowly become smaller over time, and it may eventually reach 80%-90%, which requires us to intervene manually to release the Soul village.This article will
$ Current PIN name$# the number of arguments passed to the scriptThe first parameter, and so on$*,[email protected] All parameters$$ Current Shell Process IDShell output shell name, PID, number of parametersList parameters in sequence#!/bin/bashecho"
one, special characters 1.Any character of ' * '‘? ' Any one character' # ' comment characters' \ ' de-semantic characters' | ' Pipe characterMost of them have been used before, for the caret ' \ 'Examples of the use of the caret2. Several
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