美文网首页
05-echo命令

05-echo命令

作者: 山的那边是什么_ | 来源:发表于2018-06-16 11:21 被阅读5次

    1.显示普通字符串:

    echo "It is a test"
    

    2.显示转义字符

    echo "\"It is a test\""
    
    "It is a test"
    

    3.显示变量

    read 命令从标准输入中读取一行,并把输入行的每个字段的值指定给 shell 变量

    #!/bin/sh
    read name 
    echo "$name It is a test"
    

    以上代码保存为 test.sh,name 接收标准输入的变量,结果将是:

    [root@www ~]# sh test.sh
    OK                     #标准输入
    OK It is a test        #输出
    

    4. 显示结果定向至文件

    echo "It is a test" > myfile
    

    5. 显示命令执行时间

    echo `date`
    

    相关文章

      网友评论

          本文标题:05-echo命令

          本文链接:https://www.haomeiwen.com/subject/wtxbeftx.html