10. Shell echo命令
Shell echo命令
1.echo string
1.显示普通字符串:
1.echo "It is a test"1.echo It is a test
2.显示转义字符
1.echo "\"It is a test\""1."It is a test"
3.显示变量
4.显示换行
5.显示不换行
6.显示结果定向至文件

7.原样输出字符串,不进行转义或取变量(用单引号)
8.显示命令执行结果
Last updated
Shell echo命令
1.echo string
1.显示普通字符串:
1.echo "It is a test"1.echo It is a test
2.显示转义字符
1.echo "\"It is a test\""1."It is a test"
3.显示变量
4.显示换行
5.显示不换行
6.显示结果定向至文件

7.原样输出字符串,不进行转义或取变量(用单引号)
8.显示命令执行结果
Last updated
1.#!/bin/sh
2.read name
3.echo "$name It is a test"1.[root@www ~]# sh test.sh
2.OK #标准输入
3.OK It is a test #输出1.#!/bin/bash
2.read name
3.echo '$name it is test'1.[root@localhost lcr]# ./helloworld.sh
2.ok
3.$name it is test1.#!/bin/bash
2.read name
3.echo "$name it is test"1.[root@localhost lcr]# ./helloworld.sh
2.haha
3.haha it is test1.echo -e "OK! \n" # -e 开启转义
2.echo "It it a test"1.OK!
2.
3.It it a test1.#!/bin/sh
2.echo -e "OK! \c" # -e 开启转义 \c 不换行
3.echo "It is a test"1.OK! It is a test1.echo "It is a test" > myfile1.[root@localhost lcr]# ./helloworld.sh
2.[root@localhost lcr]# ls
3.helloworld.sh myfile 公共 视频 文档 音乐
4.mediawiki-1.29.0.tar.gz perl5 模板 图片 下载 桌面
5.
6.[root@localhost lcr]# vim myfile 1.echo '$name\"'1.$name\"1.echo `date`1.Thu Jul 24 10:08:46 CST 20141.[root@localhost lcr]# ./helloworld.sh
2.2017年 09月 15日 星期五 00:47:32 CST