当前位置:网站首页>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!
边栏推荐
- AES简单介绍
- 1. Connection between Jetson and camera
- 一文纵览主流 NFT 市场平台版税、服务费设计
- Programming with C language: calculate with formula: e ≈ 1+1/1+ 1/2! …+ 1/n!, Accuracy is 10-6
- Matlab [functions and images]
- Advanced C language pointer (Part 2)
- 3、Modbus通讯协议详解
- How can enterprises and developers take the lead in the outbreak of cloud native landing?
- factory type_id::create过程解析
- 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
猜你喜欢

《微机原理》—总线及其形成

【面试必刷101】链表

factory type_id::create过程解析

TV size and viewing distance

公网集群对讲+GPS可视追踪|助力物流行业智能化管理调度

避免按钮重复点击的小工具bimianchongfu.queren()

一文纵览主流 NFT 市场平台版税、服务费设计
![Matlab [function derivation]](/img/ba/9fb9da8a458d0c74b29b21a17328fc.png)
Matlab [function derivation]

TypeError: __init__() got an unexpected keyword argument ‘autocompletion‘

Matlab tips (23) matrix analysis -- simulated annealing
随机推荐
Nacos - Configuration Management
Nacos - 配置管理
Foundation: 2 The essence of image
Model and view of QT
爬虫知识点总结
Principle and application of single chip microcomputer - off chip development
Shell脚本-read命令:读取从键盘输入的数据
截图小妙招
长安链同步节点配置与启动
你了解数据是如何存储的吗?(C整型和浮点型两类)
FreeRTOS学习简易笔记
Advanced API
Shell脚本-case in语句
DataBinding源码分析
MATLAB【函数求导】
日常办公耗材管理解决方案
[untitled]
Yolov3, 4, 5 and 6 Summary of target detection
Bimianhongfu queren()
Centos7 shell script one click installation of JDK, Mongo, Kafka, FTP, PostgreSQL, PostGIS, pgrouting