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
in a variety of Internet + digital era, Linux operations have become increasingly automated direction, more and more operators run in the automated operation of the road. The most popular operational automation languages currently under Linux are
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
Executes the command and uses the command state return value to determine certain statesecho $?0 stands for Success, not 0 for unsuccessfulTo test an expressionNumerical comparison-eq equalsThe return value is 1, indicating 2 is not equal to 3-ne
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
If one, if base 1, single branch 1.1 syntaxif语句语法 单分支结构语法: if [条件]; then 指令 fi 或 if [条件] then 指令 fi1.2 Examples[[email protected] day4]# cat if-single1.sh #!/bin/sh#功能:单分支if结构整数比较,用-lt格式例子#created by
Break:Berak statements are usually used in loop statements and switch statements, and when the break statement is used in a do-while, for, and while Loop statement, the program terminates the statement following the loop. Usually the break
View the default shell types supported in Linux:/etc/shellsEcho Output command-e support for character conversions with backslash controlControl character (requires quotation marks)
\\
Output \ Itself
\a
#/bin/bash# definition of Nginx Source package version, the script will check whether the file is in the current directory according to the version name and suffix if you need to install different versions of Nginx can modify these two variables
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=
A wildcard character? Unit # blocked command \ Screen symbol| Pipe character $ use variable ~ Home directory & put behind
>> 2> 2>>Error redirection[] Array
Cut segmentCut-d:-f 3, 4 charactersFiles under three and four columns-C Line-F
To view the commands for the terminal tool:echo $TERMThe returned results are as follows:xterm-256color
To view the command for the shell environment:echo $SHELLThe returned results are as follows:/bin/bash
Switch the shell environment: chsh
Shell script login template description, shell script Template
Write notepad and change the file suffix to sh
#! /Usr/bin/CT
# Log on to ssh
# Use the ssh server spawn in combination with Alibaba CT and send
Spawn ssh root @ ip
# Expectation
Reset
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