Special characters for Shell scripts

Source: Internet
Author: User

1. #注释作用, #! Except in addition, in the parameter replacement echo ${path#*:} here does not represent the comment, the numeral conversion, does not represent the comment echo $ ((2#101011)) 2. Command line delimiter, you can write multiple commands on a single line. echo Hello; Echo There3. ;; To terminate the case option, copy the code code as follows:
Case "$variable" inabc) echo "\ $variable = abc";; XYZ) echo "\ $variable = xyz";; Esac4. . hide file prefixes. The command is equivalent to source. Represents the current directory: Represents a single character match in the previous level of a directory regular expression
5. "", "double quotes, single quotes, where you can reference variables in double quotes, but not in single quotes, they are organized with special characters 6. \
Escape character 7. /filename delimiter, Division operation 8. ' (the button below ESC)
After the reference, the command replaces 9. :
Null command, equivalent to "NOP" can also be considered as the shell built-in command true function of the same 10. Take the inverse operator! = is not equal to 11. *
Universal match, mathematical multiplication in regular expressions * * Power Operation 12. ? In the test action regular expression,? Matches any single character 13. $ variable symbol regular expression line terminator ${} parameter replace $*,[email protected] Position parameter $? Exit status $$ process ID14. () command group, (A=hello; Echo $a), the list of commands in () runs as a child shell. The variables in () are not available for the remainder of the script because they are in the child shell. Array initialization: array= (element1, Element2, Element3) 15. {XXX,YYY,ZZZ}
Curly braces extend cat {file1,file2,file3} > Combined_file, merging File1,file2,file3 together and redirecting to Commbined_file. Cannot have spaces in curly braces
16. {} code block. In fact, this structure creates an anonymous function.    But unlike a function, the variable declared in it is still visible to the code of the rest of the script. Copy code code as follows: # Content in code block, external access, I/O redirect 1: #!/bin/bash 2:3: File=/etc/fstab 4: 5: # Variables in this code block, external can also access 6: {7:read line1 8:read line2 9:} < $File 10:11:echo "first line in $File I S "12:echo" $line 1 "13:echo 14:echo" Second line in $File is "15:echo" $line 2 "16:17:exit 0# saves the results of a block of code to a file
17. {}\;
Path names, which are generally used in the Find command, are noted; The –exec18 used to end the find command sequence. []test array elements, such as the ARRAY[1]=ABC character range, use 19 in regular expressions. [[]]
The test expression itself is placed in [] 20. (()) Mathematical calculation extension 21. >& >>& >> < redirect scriptname > FileName redirect script output to file, overwrite original content command &> filename redirect Stdou T and stderr to file command >&2 redirect stdout and stderrscriptname >> filename redirection script output to file, add to file end, if no file, create this file. 22 . << <<<
Redirect, << for "here Document", <<< for "here string"
\<, \>
The word boundary in the regular expression is grep ' \<the\> ' Testfile24. Pipeline, analyzing the output of the front command, and outputting the output as input to the command behind
>| forced redirection 26. || Logic or 27. & Background Run command, a command followed by a &, which will indicate that the copy code code is run in the background as follows:
1: #!/bin/bash 2:3: For I in 1 2 3 4 5 6 7 8 9 4:do 5:echo-n "$i" 6:done&
Note that the last done&28 for the For loop. && Logic and

Special characters for Shell scripts

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.