0 Basic Learning Cloud computing and Big Data DBA cluster Architect "Linux Bash shell Programming and system Automation January 11, 2015 Monday"

Source: Internet
Author: User

Basic Commands1.SortSort by the first letter of ASCII-n Sort Ascending by number size-R Descending Sort-u reject duplicate rows-k-t together with-K to specify the column-T Specify delimiter2.UniqReject Duplicate Rows3.seqsequenceseq Ten-represents a number starting with 1 and listing up to 10 at 1 intervals.seq 2 Ten-represents a number starting with 2 and listing up to 10 at 1 intervals.seq 1 2 Ten-represents a number starting at 1, and a list of 10 before the 2 interval.seq Ten-1 1==================================Shell1. Role2. constituent elements1FileName.SH  2) The first line of the file #!/bin/Bash3) Body variable process Judgment Statement system command3. How to execute a script1) Bash script name2)./Script Name--you need to have executable permissions on the script==========variables1. Definition: Changeable value, can be called repeatedly, change the value continuously.2. How to set: variable name =assigned value.3. How to call the $ variable name4. Classification1) Local variables: Valid only for the current environment. 2Environment variable: valid for child shell. Set the way export variable name =value5. Clear the unset variable name6. Replace1) display number of Bits ${variable name: Number 1: Number 2}--Show starting from number one, number two represents several notes: counting starts from zero [email protected]~]# num=123456789[[Email protected]~]#Echo${num:1:6}234567   2) culling some start characters [[email protected]~]#Echo${file#/tmp}/a/b/c/d/e/f/Test3keep only the file name [email protected]~]#Echo${file##/*/}test 4) Change the file suffix name in volume [[email protected] ~]# echo ${file%}.sh/tmp/a/b/c/d/e/f/test.sh[[email protected] ~]# echo ${file%.txt}.sh7. Type variables use declare to declare variable types [[email protected] ~]# a=1[[email protected] ~]# b=2[[email  protected] ~]# c=a+b[[email protected] ~]# echo $a 1[[email protected] ~]# echo $b 2[[email  Protected] ~]# echo $ca +b[[email protected] ~]# declare-i a=1[[email protected] ~]# declare-i B=2[[email&nbsp  ;p rotected] ~]# declare-i c=a+b[[email protected] ~]# echo $C 3$ (()) represents an arithmetic expression, [[email protected] ~]# c=$ (($a + $b)) [[email protected] ~]# echo $c ==========================================1. Conditional Judgment Statement if condition-->condi tion refers to the condition of the judgment then CMD1--and CMD1 refers to the statement executed after satisfying the judgment condition else CMD2--CMD2 refers to the statement that does not meet the judgment condition execution Fiif C   Onditionthen cmd1elif conditionthen cmd2else cmd3firead can be used to assign keyboard input to a variable usage read variable name value READ-P "hint information" variable name 2.test judgment Man Test View related judgment instruction usage [] number judgment-gt greater than-ge greater than or equal to-LT  -le less than or equal to-ne is not equal to-eq equals the character's judgment-Z null = Word typeface, etc.! = Character not equal-n non-null logic with-a logic or-O file judgment-D file is not a directory-F is a plain file-E File is not present =======================for:1. Function: Loop statement usage for variable in value range do cmddonefor i in Test1 test2 {1..10} $ (seq   1) do cmddone command line mode: For I in {1..10};d o echo $i;d one===========================================while Loop statement usage while    Condition-to-meet condition executes the cmd do cmd donebash-x in debug mode to run the script to show the process of running the script until loop statement usage: until     Condition---condition does not satisfy the use of cmd do cmd donecase multiple conditional judgment Statement usage: Case value in value 1) CMD1;;     Value 2) CMD2;;     Value 3) CMD3;;        *) * represents all the above values, do some operations. CMD4;;         The esaccontinue action in the Loop statement represents a jump out of this loop into the next loop. Break acts in a loop statement to represent a direct jump out of the loop. Continue example: For I in {1..10}do  If [$i-eq 5] Then continue fi echo $idone [[[Email protected] tmp]# bash Example of continue.sh 1234678910break CExample of ontinue: For i in {1..10}do if [$i-eq 5] then break fi Echo $idone [[email protected] tmp]# bash break.sh 1234 think: Require output 100 below all can be divisible by 7, but can not be divisible by 5 number.

0 Basic Learning Cloud computing and Big Data DBA cluster Architect "Linux Bash shell Programming and system Automation January 11, 2015 Monday"

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.