Shell local variables, environment variables, clear variables and location variables

Source: Internet
Author: User
Shell local variables, environment variables, clear variables and location variables 1 local variables: the scope is in a shell, close the terminal, and then enable one. The declared variables are gone; after the variable is set to read-only, it cannot be discarded or modified. Variable Declaration LOCALTEST & amp; lsquo; HELLO, BA shell local variables, environment variables, clear variables and location variables 1 local variables: scope in a shell, close the terminal, and then enable one, the declared variable is missing. the variable cannot be discarded or modified after it is set to read-only. # Variable declaration LOCALTEST = 'Hello, baby' # variable view echo $ LOCALTEST # View all variables set # set variables to read-only readonly LOCALTEST # View read-only variables readonly 2 environment variables: it can be used in all user processes. The logon process is a parent process, and the shell process is a child process. When the parent process initializes environment variables, all child processes can use them. # Variable declaration file/etc/profile (for all users) or/home/guest /. bash_profile (for guest users) # variable declaration export JAVA_HOME = '/usr/local/jdk7' # variable view echo $ JAVA_HOME # View All environment variables 3 clear variables: the local variable does not exist after it is cleared, and the environment variable does not exist in all processes after it is cleared, but it does not exist in the file. You can use the source command to restore the variable. Readonly variables cannot be unset variable_name. 4 location variables: $0, $1, $2, $3, $4, $5, $6, $7, $8, $9. $0: Script name; the other nine are parameters passed during script execution. ./Rm_file.sh xxx.img,fff.txt
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.