-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash-shell-tutorial-wildcards.t2t
57 lines (41 loc) · 2.48 KB
/
bash-shell-tutorial-wildcards.t2t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
WIKINAME
<TITLE>
Cai Yuanqing <[email protected]>
%!includeconf: config.t2t
%!postproc: '(?i)(</title>)' ' <this-file-name>\1'
%!postproc: '(?i)(<body)' '\1 id="<this-file-name>"'
%%!include: menu.t2t
%%% Some post processing filter magic (search & replace)
% meta: keywords
%!postproc: (</HEAD>) <meta name="keywords" content="txt2tags, convert, conversion, online, text, HTML, XHTML, SGML, LaTeX, Lout, Man page, Wikipedia, Google Code Wiki, DokuWiki, MoinMoin, MagicPoint, PageMaker, Python, free, tool, markup, Linux, Mac, Windows, GPL">\n\1
% meta: description
%!postproc: (</HEAD>) <meta name="description" content="txt2tags - Convert plain text to HTML, XHTML, SGML, LaTeX, DocBook, Lout, Man page, Creole, Wikipedia, Google Code Wiki, DokuWiki, PmWiki, MoinMoin, MagicPoint, PageMaker, AsciiDoc and ASCII Art!">\n\1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Start
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
= 5. 通配符 =
如果你用过Unix或者任何Linux,通配符对你应该并不陌生。
在shell通配符的作用显然没有必要再做过多的解释,这一章我们仅仅来回顾看看在shell脚本中,通配符是如何使用的,不同的语法又有什么不同的效果,以及在脚本和shell中是否有不同之处?
考虑下如何将/tmp/a目录下的文件都拷贝到/tmp/b目录下,那如果是所有的.txt文件又该怎么做呢? 所有的.html文件呢?
希望你早已经想到了下面的这几行:
========================================================
```
$ cp /tmp/a/* /tmp/b/
$ cp /tmp/a/*.txt /tmp/b/
$ cp /tmp/a/*.html /tmp/b/
```
========================================================
那么你是否知道不是用//ls /tmp/a//如何列出/tmp/a目录下的文件吗?
也许你回想到//echo /tmp/a/*//,那它和//ls//的输出有什么不同呢? 我们如何来使用它?
怎样将所有的.txt文件重命名为.bak文件呢?
试试
```
$ mv *.txt *.bak
```
也许这无法达到我们想要的效果吧。
考虑下参数是如何在shell中展开并传给//mv//的,可以使用//echo//来试试,如果你觉得更有效。
我们将在后面的章节进一步学习通配符,它涉及到一些我们现在还没有学习的部分,所以我们可以边学边看:-D
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%!include: footer.t2t