当前位置:网站首页>Shell script echo command escape character
Shell script echo command escape character
2022-07-01 08:48:00 【Little snail's way】
echo It's a Shell Built in command , Used to output a string at the terminal , and Add line break at the end by default .
Output does not wrap
echo After the command is output, the default line will wrap , If you don't want a new line , You can add -n Parameters , As shown below :
#!/bin/bash
name="Tom"
age=20
height=175
weight=62
echo -n "${name} is ${age} years old, "
echo -n "${height}cm in height "
echo "and ${weight}kg in weight."
echo "Thank you!"
Output :
Tom is 20 years old, 175cm in height and 62kg in weight.
Thank you!
Output escape characters
By default ,echo Will not parse with backslash \ The escape character at the beginning . such as ,\n Means line break ,echo It will be treated as a normal character by default . Please see the following example :
[[email protected] ~]# echo "hello \nworld"
hello \nworld
Parameters :-e
We can add -e Parameters to make echo Command parses escape characters
[[email protected] ~]# echo -e "hello \nworld"
hello
world
Escape character :\c
With -e Parameters , We can also use escape characters \c Mandatory echo The command doesn't wrap
#!/bin/bash
name="Tom"
age=20
height=175
weight=62
echo -e "${name} is ${age} years old, \c"
echo -e "${height}cm in height \c"
echo "and ${weight}kg in weight."
echo "Thank you!"
Output :
Tom is 20 years old, 175cm in height and 62kg in weight.
Thank you!
边栏推荐
- Matlab [functions and images]
- V79.01 Hongmeng kernel source code analysis (user mode locking) | how to use the fast lock futex (Part 1) | hundreds of blogs analyze the openharmony source code
- 又到年中,固定资产管理该何去何从?
- 大型工厂设备管理痛点和解决方案
- Nacos - 配置管理
- Vscode customize the color of each area
- NFT监管要点和海外政策
- Audio-AudioRecord create(一)
- What are the differences between the architecture a, R and m of arm V7, and in which fields are they applied?
- 避免按钮重复点击的小工具bimianchongfu.queren()
猜你喜欢

电脑小技巧

Matlab tips (23) matrix analysis -- simulated annealing

Embedded Engineer Interview Question 3 Hardware

ARM v7的体系结构A、R、M区别,分别应用在什么领域?

内存大小端

MATLAB【函数和图像】

How can enterprises and developers take the lead in the outbreak of cloud native landing?

Audio-AudioRecord create(一)

TV size and viewing distance

《单片机原理及应用》—定时器、串行通信和中断系统
随机推荐
1. Connection between Jetson and camera
Principle and application of single chip microcomputer - principle of parallel IO port
Shell脚本-for循环和for int循环
集团公司固定资产管理的痛点和解决方案
Shell脚本-echo命令 转义符
《微机原理》-绪论
NFT监管要点和海外政策
明明设计的是高带宽,差点加工成开路?
任务、线程、进程 区别
Jeecg restart alarm 40001
Matlab tips (23) matrix analysis -- simulated annealing
MATLAB【函数求导】
目标检测的yolov3、4、5、6总结
SPL installation and basic use (II)
Nacos - service discovery
Computer tips
Insert mathematical formula in MD document and mathematical formula in typora
[untitled]
TypeError: __init__() got an unexpected keyword argument ‘autocompletion‘
Redis——Lettuce连接redis集群