Special symbols in linuxshell programming

Source: Internet
Author: User
Special symbols 1 and #1 in linuxshell programming. comment a line in the script file. 2. the quotation marks and \ symbols are not followed by comments, except that # itself: echo & quot; 12 # hehe & quot; echo & amp; #39; 12 # hehe & amp; #39; echo12 \ # hehe3; replace echo $ (PAT... special symbols 1 and #1 in linux shell programming. comment a line in the script file. 2. the quotation marks and the \ symbol are not comments, but the # symbol itself: echo "12 # hehe" echo '12 # hehe 'echo 12 \ # hehe 3. replace echo $ (PATH # * :) www.2cto.com 4. convert echo $(16 # )); convert hexadecimal number a to decimal number to echo $(5 #3 )); convert decimal number 3 to decimal number 5. the pattern matches echo $ {# string} to get the number of characters contained in the variable string. if the string is an array, returns the number of characters contained in the first element of the array. Www.2cto.com 2. semicolon; 1. delimiter. use semicolons in the same line to separate two commands: ls; cat hello 2. after the quotation marks and the \ symbol, it is not a delimiter, but the number itself. 3.; 1. two semicolons as the final character of the case option: case "$ variable" in abc) echo "$ variable = abc"; xyz) echo "$ variable = xyz"; esac IV. periods. 1. a file starting with a dot is a hidden file, which must be viewed using ls-. 2. a vertex refers to the current directory, and two vertices refer to the parent directory. 5. quotation marks 1 and double quotation marks "" most letters or symbols in double quotation marks represent itself. 2. all letters or symbols in single quotation marks represent itself www.2cto.com, A comma is used to separate multiple arithmetic expressions and calculate each expression, but only returns the value of the last expression. Let "t = (a = 9,5 + 3)" # In this expression, assign a value to a as 9, it is calculated that t is octal. the backslash \ indicates that the symbol behind the symbol only represents the symbol itself, but only one is valid. For example, \ a and 'A' have an effect 8, forward slash/1, and a file name delimiter, such as/usr/locale/share/2, Division symbol 9, anti-quote 'command to replace? Www.2cto.com 10, Colon: 1, empty command, return value is 0, like the true command, can be in the infinite loop conditions. 2. there is a binary command to be executed following the reminder: $ {username = 'whoam'} # if not, this row will have an error. 3. parameter substitution? :$ {HOSTNAME ?} 4. create a file (if not) with the> redirection symbol, or cut off a file (the file already exists). The file length is 0:> data.exe and cat/dev/null> data.exe have the same effect. 5. update the access and modification time of a file with the> redirection symbol. if the file does not exist, create it. Same as touch, note that both 4 and 5 work only for rule files, for pipelines, soft connections and some special files are not used. 6. domain delimiters such as the colon 11 and exclamation point in the middle of the $ PATH variable! 1. if it is not a number, change the exit status from 0 to 1, and change from equal to = ,! = 2. indirect variable reference? 3. two exclamation marks indicate the previous command !! 12. asterisks * 1. wildcard characters can be used in regular expressions to replace any character or number 2, multiplication number 3, and two asterisks to represent the Index ** www.2cto.com 13, question mark? 1. test symbol, used for condition testing? 2. wildcard, which can replace a character or number fourteen in a regular expression, $1, variable symbol 2, indicating the termination of a line 3, $ {} variable instead of 4, $1, $2, $3, and so on are the first, second, and third parameters input to the script from the command line. $0 indicates the script itself. 5. $ # indicates the number of parameters input from the command line to the script. 6. $ * refers to all parameters input from the command line to the script, but is considered as a word. 7. $ @ refers to all parameters input from the command line to the script, but each parameter is separated according to the IFS variable. For example: export IFS = ':' and then echo $ PATH. The result is: /usr/local/sbin/usr/local/bin/usr/games/usr/lib/apache-ant/bin/usr /lib/java/bin/usr/lib/java/jre/bin/usr/lib/qt/bin/usr/share/texmf/bin 8, $ ?, Exit status variable. 9. $, process ID. Www.2cto.com 15th, parentheses () 1, command group (a = 123; echo $ a) This Command Group writes a subscript, the variables in the subscript are invisible to all scripts other than the subscript. 2. array initialization array = (element1 element2 element3) Sixteen, braces {} 1, and parentheses extension? For example, grep linux file *. {txt, htm *} Searches for linux strings 2, code blocks in file2.txt,file1.htm,file1.html and other files. as a sub-function, it cannot be used in a terminal. the variables in the sub-function are still visible to other scripts. 3. functions in the code block can redirect input and output. {Read line1 read line2} </etc/fstab

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.