Tagged with: Linux centos Shell wildcard8.1shell IntroductionThe shell is a command interpreter that provides human-computer interaction.Supports specific syntax.Each user can have their own specific shell (bash).CentOS7 default bash (Bourne Agin
Shell Special Symbol _cut command概念:cut命令用来截取某一个字段格式:cut -d ‘分割字符‘ [-cf] n,这里的n是数字,该命令选项有如下几个:- d 后面跟分割字符,分割字符要用单引号括起来- c 后面接的是第几个字符- f 后面接的是第几个区块The Cut command uses the following
[Email protected] do]# cat/etc/passwd
Shell Introduction
The shell is a command interpreter that provides interaction between the user and the machine
Support for specific grammars, such as logical judgments, loops
Each user can have their own specific shell
CentOS7
Shell IntroductionThe shell is a command interpreter that provides interaction between the user and the machineFor example, we have remote login tool, it is actually a shellThe CentOS default shell is bash (Bourne Agin Shell)·Command historyHistory
Shell script +expect deploying SSH in bulkFirst, the preparation of work and ideas1, three machines to do experiments (centos6.5, ip:192.168.0.22 (master control), 192.168.0.156, 192.168.0.157)2,ip:22 this one control machine, the other 2 do the
Variable
Variables are abstract concepts that can store calculated results or can represent values. Variables can be accessed by variable names.
Variable declarationDeclaring variables is generally used in the following
1. When type cycle and until type cycleWhile using a few, the general daemon program or always loop execution will be used, the other loop operations are used for instead.1.1 Type and until type loop syntax(1) While conditional
1. string Judgments
STR1 = str2
True when two strings have the same content, length
Str1! = str2
True when strings str1 and str2 are unequal
-N str1
True when the length of a string is
1.1 The following table is a common two-dimensional comparison operatorWe can also see through the man testTips(1) The ".(2) the ">" symbol is greater than the meaning, if[["$a" > "$b"]], if[["$a" \> "$b"]. You need to escape in parentheses because
Parameter related knowledge${parameter:-word}: If parameter is empty or undefined, the variable is expanded to "word"; otherwise, the value of parameter is expanded; ${parameter:+word}: If parameter is empty or undefined, do nothing; otherwise,
1. Batch Add UsersCreate a TXT file for the user name and password combination userdata.txt, as follows:123123 123 123 123 123The script to add the above users in bulk is:#! /bin/Bash whileRead Line Dousername=$(Echo$line |Cut-f1-d' ') #或 username=
In order to make the shell script have a certain "judgment" ability, according to different conditions to accomplish different management tasks. Make the script a certain "smart".First, condition test operationFile Test Common operations:-D:: Test
Shell Preparation1. Identify the shell typeEchoEcho $BASHEcho $SHELLThe top three command results are:/bin/bash2, Terminal common operationA, delete a single character c+h or BACKSPACE keyB. Delete single word c+wC, delete a single row c+ud, repeat
Tag: Shell script if statement Yang Shufan Shell $?In a simple shell script, each statement is executed sequentially in order to automate the batch process. However, a single sequential structure makes scripting less intelligent and difficult to
Presumably everyone knows "if ... So ... " The application of this grammar!Of course, Linux for this kind of usage is also considered, many times we need to write a shell script, it is unavoidable to avoid the IF statement.For example: Determine if
1. Basic IdeasHill sort is to group records by a certain increment of the subscript, sorting each group using the direct insertion sorting algorithm; As the increments gradually decrease, each group contains more and more keywords, when the
Description of function definition formats, function parameters, and Shell functions
You can use shell to define a function, and then use it in a shell script. The Function Definition Format in shell is as follows:
[ function ] funname [()]{
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