Learn the shell happily

Source: Internet
Author: User

/bin/bash is the default shell for Linux

setting, reading, and deleting variables

Example: Name=zhangsan echo $name unset name

You can view the value of the Echo $HOME $PATH of the environment variable

Variable setting, there can be no spaces on both sides of the equal sign

Variable names can only be alphanumeric, but the start character cannot be a number

Variable contents can be enclosed in single or double quotation marks if there is a space character.

The $ symbol within the double quotation marks retains the original attribute, and the $ symbol within the single quotation mark is just a general character

Example: Name= "I am $USER" echo $name---i am root

Back quote echo ' Date ' or echo $ (date)

Extension variable contents can use "$ variable name " to accumulate content path= "$PATH":/home/zhangsan

You can use export to turn user variables into environment variables export name

env command to view all environment variables and values in the current shell environment

The SET command can view all custom variables and environment variables

The subroutine inherits only the environment variables of the parent program and does not inherit the parent program's custom variables

Read-p followed by the prompt character-T followed by the number of seconds to wait for the variable name

Read name what you enter from the keyboard is the value of the name variable

Read-p "What is your name?"-T 5 name prompts the user to enter their own name as the value of the name variable within 5 seconds




Learn the shell happily

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.