Shell scripting Getting Started learning notes

Source: Internet
Author: User between the operating system and the user. Responsible for interpreting the command line

2./etc/shells Record login system effectively supports Shell

3./ETC/PASSWD Finally, someone who can see the user's default shell

4. Directly enter the name of the shell to switch the shell

Records of the command can be viewed with history history-c clear

Historical commands are stored in the. bash_history file instructions can be replaced with alias alias = actual name

Cancel with Unalias alias variables

<1> Define variable name = variable value to output variable value with echo $ variable name

Note: Using {$ variable name} can be associated with other variables such as echo{$ variable name}_ variable name Display variable Value _ variable name

<2> Assignment (double-cited, single-quote, anti-apostrophe)

Double cited: Agree $ reference Variable value output echo "xx xx $ variable name" displays XX xx variable value

Single cited: Do not agree with the value of the reference variable the same as the xx xx $ variable name

Anti-apostrophe (Tab key): (The backslash must be a command that can be run and its command combination) assigns the result of the command to the value

Read assignment: Read + variable name will need to manually enter a variable value to the variable name at the keyboard

If you read+ multiple variable names, separate the values of the input variables with a space.

More useful Commands read-p "Please input xxxxx:" + variable name

The scope of the <3> variable

The export variable name can declare a variable as a global variable (this variable can be used in a child shell)

be able to export XX = xxx at the time of definition

Use the unset variable name to eliminate

Operation of <4> variables


$2 Add expr $X + $Y//plus no spaces on both sides show values + values

2 USD Multiply expr $X \* $Y


<5> Rules:

Variable name = variable value equal to cannot have spaces at both ends

Variable names can only be used in letters and numbers, where numbers cannot begin

If there are spaces that need to be enclosed in double or single quotes (the special character of the double-characters is the original meaning, the single-quote is only a character meaning. See <2>)

If necessary, you can use the escape character \

Ability to view the shell's pre-defined variables with the env command (env | more)

Variable PS1 is the input command, the preceding string can be changed by itself.

8. Redirection

Standard output redirection:

> Write, overwrite

>> Append

Standard input redirection:

< read files

Standard error 2>

9. Execution Environment settings



10. Run the shell

./full path/shell (current folder./shell)

Interpreter +shell (bash shell)

Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

Shell scripting Getting Started learning notes

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: 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.