linux复习笔记 之bash shell (3) 通配符
2015-01-16 09:02
316 查看
转载请出自出处:http://eksliang.iteye.com/blog/2104387
在bash的操作环境中有一个非常有用的功能,那就是通配符。
下面列出一些常用的通配符,如下表所示
实例一:找出/etc/下面以cron为开头的文件名
实例二:找出/etc/下面文件名刚好是五个字母的文件名
实例三:找出/etc/下面文件名含有数字的文件名
实例四:找出/etc/下面文件名开头为小写字母的文件名
实例五:将/etc/目录下面文件名开头为小写字母的文件名复制到/tmp目录下
在bash的操作环境中有一个非常有用的功能,那就是通配符。
下面列出一些常用的通配符,如下表所示
符号 | 意义 |
* | 万用字符,代表0个到无穷个任意字符 |
? | 万用字符,代表一定有一个任意字符 |
[] | 代表一定有一个在中括号内的字符。例如:[abcd]代表一定有一个字符,可能是a、b、c、d这四个中的任何一个 |
[-] | 若有减号在中括号时,代表在编码顺序内的所有字符。例如:[0-9]代表0到9之间的所有数字,因为数字的语系编码是连续的 |
[^] | 若中括号内的第一个字符为指数符号(^),那么表示反向选择,例如:[^abcd]代表一定有一个字符,只要不是a、b、c、d中一个就可以 |
[root@bogon ~]# ll -d /etc/cron* drwxr-xr-x. 2 root root 4096 Apr 25 09:04 /etc/cron.d drwxr-xr-x. 2 root root 4096 Apr 25 09:05 /etc/cron.daily ....
实例二:找出/etc/下面文件名刚好是五个字母的文件名
[root@bogon ~]# ll -d /etc/????? drwxr-x---. 2 root root 4096 Apr 25 09:04 /etc/audit drwxr-xr-x. 2 root root 4096 Apr 25 08:59 /etc/avahi drwxr-xr-x. 2 root root 4096 Feb 21 2013 /etc/blkid ......
实例三:找出/etc/下面文件名含有数字的文件名
[root@bogon ~]# ll -d /etc/*[0-9]* drwxr-xr-x. 4 root root 4096 Apr 25 08:58 /etc/dbus-1 -rw-r--r--. 1 root root 5139 Apr 17 2012 /etc/DIR_COLORS.256color drwxr-xr-x. 3 root root 4096 Apr 25 08:59 /etc/gnome-vfs-2.0 ......
实例四:找出/etc/下面文件名开头为小写字母的文件名
[root@bogon ~]# ll -d /etc/[a-z]* drwxr-xr-x. 3 root root 4096 Apr 25 08:59 /etc/abrt drwxr-xr-x. 4 root root 4096 Apr 25 09:04 /etc/acpi -rw-r--r--. 1 root root 44 Aug 14 03:01 /etc/adjtime ...
实例五:将/etc/目录下面文件名开头为小写字母的文件名复制到/tmp目录下
[root@bogon ~]# cp -a /etc/[a-z]* /tmp
相关文章推荐
- linux复习笔记之bash shell (4)管道命令
- linux复习笔记之bash shell (5) 关于减号-的作用
- Linux Bash Shell预处理通配符
- Linux复习笔记(一) -- Bash的基本操作
- Linux学习笔记 认识bash这个shell
- Linux 学习笔记 -- 第三部分 学习 shell 与 shell script -- 第11章 认识与学习 bash
- Linux学习笔记:bash特性之多命令执行,shell脚本
- Linux笔记(shell基础,历史命令,命令补全/别名,通配符,输出重定向)
- 【linux学习笔记】bash学习之login shell与non-login shell(source命令)
- linux bash shell 笔记
- Linux Bash Shell 笔记
- linux笔记:shell基础-bash变量
- Linux Bash Shell学习笔记
- linux笔记:shell基础-bash基本功能
- Linux Bash Shell学习(二):目录和通配符
- linux笔记:shell基础和bash的基本功能
- linux复习笔记之bash shell (2) bash基础
- Linux-shell基础复习笔记
- [linux_shell]Bash通配符与特殊符号
- Linux bash shell special characters and script syntax.