Linux Bash Shell万用字元与特殊符号

运维 系统运维
由于在 bash 当中常会使用到一些万用字元,与搭配特殊符号来将指令做更好的利用(例如最常提到的正规表示法 Regulare Express )!底下我们列出一些常用的万用字元与特殊符号!

由于在 Linux Bash Shell当中常会使用到一些万用字元,与搭配特殊符号来将指令做更好的利用(例如最常提到的正规表示法 Regulare Express )!底下我们列出一些常用的万用字元与特殊符号!
   
上面的万用字元当中,最常用的就属 *, ?, [] 及 ` 了!我们提几个简单的例子:
[test @test test]# ls test* <==那個 * 代表後面不論接幾個字元都予以接受(沒有字元也接受!)
[test @test test]# ls test? <==那個 ? 代表後面『一定』要接『一個』字元
[test @test test]# ls test??? <==那個 ??? 代表『一定要接三個』字元!
[test @test test]# cp test[1-5] /tmp <==將 test1, test2, test3, test4, test5 若存在的話,就拷貝到 /tmp 下
[test @test test]# cd /lib/modules/`uname -r`/kernel/drivers <==被 ` ` 括起來的內容『會先執行』!

上面几个例子相当的有趣!尤其是***面两个!需要注意的是, [] 里面『代表只有一个字元』但是范围可以由 1-5 ,这样来说的话,那么我们如果允许『大写字元』就可以将档案 copy 出来的话,可以这样做:
cp *[A-Z]* /tmp
很有趣吧?! ^_^

此外,那个 `` 里面的『指令』会先被执行,也就是说:
1. 系统先执行 uname -r 找出输出的结果;
2. 将结果累加在目录上面,来执行 cd 的功能!
很棒吧!!这些基本的功能需要特别来了解一下才行呦!

【编辑推荐】

  1. Linux Bash命令关于程序调试详解 
  2. Linux Bash命令关于快捷键应用
  3. Linux Bash Shell系统的应用详解
  4. Linux Bash具体安装步骤及使用介绍
  5. Linux Bash命令查询相关事件详解
     
责任编辑:chenqingxiang 来源: Linux社区
相关推荐

2014-08-01 17:12:14

Linux特殊符号

2021-05-11 22:24:56

C++符号Tab

2013-06-03 09:45:53

R语言

2010-03-11 17:57:48

Python正则表达式

2010-06-23 16:35:50

Linux Bash

2010-06-23 17:37:14

Linux Bash

2010-06-23 17:34:03

Linux Bash

2010-06-23 17:29:07

Linux Bash

2010-06-23 16:31:10

Linux Bash

2010-06-23 17:16:33

Linux Bash

2023-03-22 18:33:05

Bash变量

2019-08-02 09:13:22

Linux脚本语言欢聚时代

2010-06-23 11:09:14

Linux Bash

2010-06-23 16:05:36

Linux Bash

2023-07-27 17:41:02

BashZshFish

2010-06-23 17:26:01

2010-06-23 17:07:47

Linux Bash

2009-12-25 09:47:05

LinuxShell编程bash

2010-06-23 15:55:36

Linux Bash

2010-06-23 16:09:40

Linux Bash
点赞
收藏

51CTO技术栈公众号