Shell Learning variables and quotes

Source: Internet
Author: User

1. The concept of variables: variables are stored in the program of the user's memory space, the variable name is the address of this memory space, the value of the variable is stored in the computer memory. Variable definition: It is simple to understand that a variable is a key-value relationship pair in memory, as follows a can be understood as its in-memory address, 1 for its specific content.

[[email protected] ~]# A=1[[email protected] ~]# echo $A1

2. Variables and quotation marks: There are three kinds of quotation marks in the shell, single quotation mark ', double quotation mark "" and "anti-quotation mark" `,其中单引号括起来的字符都作为普通字符出现;双引号括起来的字符除了$ \ , these characters still retain their special function, the remaining characters are still normal characters, the contents of the anti-quotation marks are first interpreted by the shell as command execution, and their output as the subsequent input.

双引号"$ \ `` ‘‘ 可以转义 "[[email protected] ~]# str="hello world"#被双引号括起来的 hello+空格+world 作为一个字符串赋值给了str[[email protected] ~]# echo $strhello world
反引号``[[email protected] ~]# pwd/root[[email protected] ~]# MyDir=`pwd`#pwd命令获取当前的目录位置,然后把该位置赋值给MyDir[[email protected] ~]# echo $MyDir/root
综合的#!/bin/bashD="Play"A=""pwd"+‘pwd‘+`pwd`-$D-"$D"-‘$D‘-`$D`"echo $A结果:[[email protected] ~]# sh test.sh test.sh: line 3: Play: command not foundpwd+‘pwd‘+/root-Play-Play-‘Play‘-

Shell Learning variables and quotes

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.