Special symbols in linux shell Programming

Source: Internet
Author: User

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.