Skip to Content
bash shell脚本编程经典实例 (第2版)
book

bash shell脚本编程经典实例 (第2版)

by Carl Albing, JP Vossen
January 2021
Intermediate to advanced
581 pages
15h 7m
Chinese
Posts & Telecom Press
Content preview from bash shell脚本编程经典实例 (第2版)
30
2
2.3
13.15
15.6
19.1
A.11
A.12
2.2
 保留输出中的空白字符
2.2.1
 问题
你想要保留输出中的空白字符。
2.2.2
 解决方案
将字符放入引号中。在上一节的示例中加入引号就可以保留空白字符:
$
echo "this was very widely spaced"
this was very widely spaced
$
或者:
$
echo 'this was very widely spaced'
this was very widely spaced
$
2.2.3
 讨论
引号中的单词组成了
echo
命令的单个参数。该参数是一个字符串,
shell
不会干涉字符串
的内容。实际上可以用单引号(
''
)明确告诉
shell
不要干涉字符串。如果使用的是双引
号(
""
),那么
shell
还是会执行一些替换操作(变量扩展、算术扩展、波浪号扩展以及命
令替换),但上述示例不涉及这些操作,所以输出没有什么变化。如果不确定,那就用单
引号。
2.2.4
 参考
help echo
help printf
5
2.3
15.6
19.11
A.11
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

bash 网络安全运维

bash 网络安全运维

Paul Troncone, Carl Albing
Linux 内核观测技术BPF

Linux 内核观测技术BPF

David Calavera, Lorenzo Fontana

Publisher Resources

ISBN: 9787115553782