Shell Step by Step (2)--variable

Source: Internet
Author: User

3. Variable DeclarationReadOnly Read OnlyExport Modify or print environment variablesexport-p Show Current Environment
Note : It is important to note that there must be no space before and after the assignment.
# Echo Control character color [email protected]:/home/kallen/test/shell# echo-e '\e[1; 31mhello,world\e[0m'
Hello,world background color: 0 Transparent (using terminal color), 40 black, 41 red, 42 green, 43 yellow, 44 blue 45 Violet, 46 turquoise, 47 White (grey) Foreground : 30 Black 31 red, 32 green, 33 yellow, 34 blue, 35 violet, 36 turquoise, 37 white (grey) High Brightness: Highlight is 1, do not highlight is 0. Note that the string is followed by M.
-E to open escape in Echo\e or \ 033来 output ESC symbol format color: \e[background color, foreground colour, highlight mRestore defaults to \e[0mHighlight is 1, not highlight is 0note M follows the string immediately after
"Note" a file name that begins with "-" may cause problems when using "-" as the redirection operator. You should write a script to check the problem and add the appropriate prefix to the file. For example:./-filename, $PWD/-filename, or $pathname/-filename.if the value of a variable starts with "-", it may also cause problems.1 var= "-n" 2 echo $var 3 #with "echo-n" effect, so nothing will output.

~+ The current working directory, equivalent to the $PWD variable.the working directory before ~-, equivalent to the $OLDPWD internal variable.=~ is used for regular expressions, this operation will be explained in the regular expression matching section, only Version3 support.^ The beginning of the line , in the regular expression. "^" Navigates to the beginning of the line.
variable Assignment Method--(1) Direct Assignment: =(2) Let assign value: let A=16+5
Bash does not differentiate "types" from variables. In essence, bash variables are strings. but depending on the context, Bash also allows comparison operations and arithmetic operations. The key factor in determining this is whether the value in the variable is only a number.
A. Positional parametersThe {} notation is a good way to use positional parameters. This also requires an indirect reference1 args=$# # Number of positional parameters2 Lastarg=${!args}3 # or: lastarg=${!#}4 # Note lastarg=${!$#} will error

Shell Step by Step (2)--variable

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.