码迷,mamicode.com
首页 > 系统相关 > 详细

Shell基础学习(四) echo命令

时间:2016-05-30 12:44:18      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:

1、显示普通的字符串

echo "boring"

2、显示转义字符

echo "\"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 -e "OK! \n" # -e 开启转义
echo "It it a test"

 5、不显示换行

echo -e "OK! \c" # -e 开启转义
echo "It it a test"

6、显示结果定向到文件

echo "It is a test" > myfile

7、显示命定执行

echo `date`

 

Shell基础学习(四) echo命令

标签:

原文地址:http://www.cnblogs.com/huixuexidezhu/p/5541597.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!