当前位置:网站首页>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!
边栏推荐
- Full mark standard for sports items in the high school entrance examination (Shenzhen, Anhui and Hubei)
- 【C】 Summary of wrong questions in winter vacation
- ARM v7的体系结构A、R、M区别,分别应用在什么领域?
- Matlab [functions and images]
- [MFC development (17)] advanced list control list control
- 《微机原理》——微处理器内部及外部结构
- 《微机原理》-绪论
- yolov5训练可视化指标的含义
- C language student information management system
- jeecg 重启报40001
猜你喜欢
Brief introduction to AES
如何解决固定资产管理和盘点的难题?
你了解数据是如何存储的吗?(C整型和浮点型两类)
《单片机原理及应用》-片外拓展
How can enterprises and developers take the lead in the outbreak of cloud native landing?
基础:2.图像的本质
Audio-AudioRecord create(一)
factory type_id::create过程解析
一文纵览主流 NFT 市场平台版税、服务费设计
15Mo3 German standard steel plate 15Mo3 chemical composition 15Mo3 mechanical property analysis of Wuyang Steel Works
随机推荐
Differences among tasks, threads and processes
又到年中,固定资产管理该何去何从?
明明设计的是高带宽,差点加工成开路?
Do you know how data is stored? (C integer and floating point)
Properties of 15MnNiNbDR low temperature vessel steel, Wugang 15MnNiDR and 15MnNiNbDR steel plates
嵌入式工程师面试题3-硬件
如何一站式高效管理固定资产?
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
jeecg 重启报40001
C语言指针的进阶(下)
我想知道手机注册股票开户的流程?另外,手机开户安全么?
Shell脚本-if else语句
Configuration and startup of Chang'an chain synchronization node
挖财打新股安全吗
Bimianhongfu queren()
Shell脚本-case in语句
Foundation: 2 The essence of image
Brief introduction to AES
中小企业固定资产管理办法哪种好?
C语言指针的进阶(上篇)