For statement1. For statement1) IntroductionIn the actual work, often encounter a task to be executed multiple times. Each execution is simply a different object, with the same other commands. For example, create a system account based on the list
CGI according to the definition of Baidu Encyclopedia, as follows:CGI is the specification of external programs when the Web server is running, and programs written by CGI can extend server functionality. CGI applications can interact with the
One, parenthesis, parentheses ()1, single parenthesis ()?? ① Command Group. The commands in parentheses will run in a new sub-shell sequence. So the variables in parentheses cannot be used by the rest of the script. Multiple commands in parentheses
[] and [[]] can determine whether the variable is empty, [ $a] [[$a]] [ ! $a] [[! $a]] No differenceIn Linux, we can use the test command to determine if a string is empty, and the test command gives us the "-Z option" and the "-N option," which you
1.1 String test operatorThe string test operator has the function of comparing whether two strings are the same, whether the length of a string is zero, whether the string is null (NOTE: Bash distinguishes between 0-length strings and empty strings,
The content of this article is very miscellaneous, but it is not difficult to understand, do not map by example.First introduce several characters commonly used characters:1 * matches any of any characters2? Match an arbitrary character3 # comment
1. The way bash checks the environment variable file depends on how the system runs the shell, typically there are 3 ways the system runs the shell:1 shell that runs by default after the system user logs on 2 ) Non-login interactive run shell 3)
Logical-judgment logical expressions in shell scripts are used in [] (brackets):
-lt:=little than less than
-le:=little && wqual less than equals
-eq:=equal equals
-ne:=no Equal Not equal to
-gt:=greater than greater than
common syntax for conditional testing:
Syntax format
Description
[]
[] has at least one space between the boundary and the content
[[ ]]
[[] There is at least one space between the
1.!#/bin/bashThis is the first line of the shell script, and/bin/bash represents the location of the script's interpreter.2. Run the script: (1) Bash test.sh(2) Bash-x test.sh (ps:-x for observing script running state)(3) Release script
Let's start with an example: Suppose you have a test service that can start, shut down, or restart test by command, the following script simulates this feature:#!/bin/bash#test.shcase $ in start) echo "Starting service ..." sleep 1
Script Realization Man-machine Game, Machine Application random method, combined with user input to give the result, the article has two methods, the first method is the logical aspect of the script, the second is easier to understand.One: The
1, for: Read different variable values, execute the same set of commands one by one, until the value is complete exit, variable values are separated by a spaceSyntax: For variable value in value listDoCommandDone2, while: Repeated testing a
Configuration knowledge such as Vim path is shown in table:
Related configuration Files
Function description
. viminfo
User's operation history using Vim
. VIMRC
Configuration file for
Method 1: Use the wc-l commandWc-l can get the length of the current row, so the string for a single row can be obtained in this simple way, and the wc-l is the number of rows that get the current string content.The code is as follows: Echo "ABC"
Shell Script First-Custom create user and batch create user 1. build Linux users with shell scripts# vim/root/user.sh#!/bin/bash#通过脚本自定义创建用户read-p " Please enter the user name you want to create : " $Useradd $read-p " Please set the user password:
First, Shell basic applicationTarget:This case requires familiarity with the characteristics of the Linux shell environment, mainly practicing the following actions:1> switching the user's shell environment2> Practice Command History, command
In the previous section we learned about the Shell's echo command, which we'll learn from the Shell's other output command printf.The printf command mimics the printf () program in the C library.printf is defined more by the POSIX standard, so a
Functions in the shell
The function is to organize a piece of code into a small unit, and give the small unit a name, when the code is used to call the name of the small unit directly.
格式: function f_name() { ?? ?? ?? ?? ?? ?? ?
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