6. Shell echo命令

      1. echo hello world
    1. 显示转移字符

      1. echo "\"hello world\""
      2. echo \"hello world\"

      结果:

      1. "hello world"
    2. 显示变量
      reed命令从标准输入中读取一行,并把输入行的每个字段的值指定给shell变量:

      1. read name
    3. 显示换行

      1. echo -e "OK! \n" # -e 开启转义
      2. echo It is a test

      输出结果:

      1. OK!
      2. It is a test
    4. 显示不换行

      1. # !/bin/sh
      1. OK! It is a test
    5. 显示结果定向至文件

    6. 原样输出字符串,不进行转义或取变量(用单引号)

      1. echo '$name\"'

      输出结果:

      1. $name\"
      1. echo `date`

      注意:这里使用的是 反引号 `,而非单引号。
      输出结果显示当前日期:

      1. asa-virtual-machine:~$ echo `date`