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版)
122
6
子表达式,接下来是一个字面连字符和空白字符。
第二个子表达式(标记为粗体)会尝试匹配曲目编号。
([[:alpha:][:blank:]]*)-
([[:digit:]]*)
- (.*)$
这个子表达式以另一个左括号起始。曲目编号为整数,由多个数位组成(字符类
[:digit:]
),
我们将其写入另一对方括号并在后面加上一个星号,也就是
[[:digit:]]*
,以此表示方括号
中的内容(数位)重复出现
0
次或多次。接着是字面空白字符、连字符、空白字符。
最后一个子表达式匹配包括曲目名、文件扩展名在内的所有剩余内容。
([[:alpha:][:blank:]]*)- ([[:digit:]]*) -
(.*)$
括号中的
.*
是一种常见的正则表达式,并不陌生,它表示任意字符(
.
)出现任意多次
*
)。我们用美元符号结束整个表达式,以匹配字符串结尾。匹配过程区分大小写,但是
可以用
shopt -s nocasematch
bash 3.1
版本以上可用)修改这种行为。该选项会影响到
case
[[
命令。
6.8.4
 参考
有关正则表达式库的细节,详见
man regex
Linux
Solaris
HP-UX
)或者
man re_format
BSD
Mac
Jeffrey E. F. Friedl
所著的
Mastering Regular Expressions, 3rd Edition
O
Reilly
出版)
7.7
7.8
19.15
6.9
 用重定向改变脚本行为
6.9.1 ...
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