14、Linux-Shell03:echo、printf和test命令

目录

一、echo

二、printf

三、test


一、echo

echo用于输出字符串

值得关注的地方

1、转义字符\。例如,echo "\"Hello,World\" is a classic sentence for programmer"。

2、read命令用于读取一行的输入,echo可以对输入进行输出

3、\n换行,\c不换行。需要在前面加上-e才会生效。

[root@VirTrxcx test]# cat var.sh 
#! /bin/bash
echo This is a simple test.
echo Now please input a number you are thinking now:
read number
echo -e "Now,I know \c"
echo -e "you are thinking ${number}, right?\n"
echo This is another.

[root@VirTrxcx test]# ./var.sh 
This is a simple test.
Now please input a number you are thinking now:
20
Now,I know you are thinking 20, right?

This is another.

4、echo message > file

输出内容到文件,文件不存在会创建并写入,文件已存在则会覆盖内容。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值