在bash的操作环境中有一个非常有用的功能,那就是通配符。
下面列出一些常用的通配符,如下表所示
符号 | 意义 |
* | 万用字符,代表0个到无穷个任意字符 |
? | 万用字符,代表一定有一个任意字符 |
[] | 代表一定有一个在中括号内的字符。例如:[abcd]代表一定有一个字符,可能是a、b、c、d这四个中的任何一个 |
[-] | 若有减号在中括号时,代表在编码顺序内的所有字符。例如:[0-9]代表0到9之间的所有数字,因为数字的语系编码是连续的 |
[^] | 若中括号内的第一个字符为指数符号(^),那么表示反向选择,例如:[^abcd]代表一定有一个字符,只要不是a、b、c、d中一个就可以 |
实例一:找出/etc/下面以cron为开头的文件名
[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
相关推荐
Bash Shell 管理Linux
PDF电子书《Bash Shell学习笔记》,和大家分享~~
linux shell scripting with bash,讲linux下shell编程,全英文版,喜欢的下
learn bash shell~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bash shell 学习笔记
linux BASH shell脚本编程指南
3.描述 (DESCRIPTION) 4.选项 (OPTIONS) 5.参数 (ARGUMENTS) 6.启动 (INVOCATION) 7.定义 (DEFINITIONS) 8.保留字 ("RESERVED WORDS") 9.注释 (COMMENTS) 10.引用 (QOUTING) 11.参数 (PARAMETERS) 12.扩展 ( ...
Cameron Newham and Bill Rosenblattham 《Learning the bash shell》是比较好的一本入门级经典教材,学linux shell 的不妨下来看看,不过是英文版的。
Bash shell编程参考手册,Linux编程必备。
bash shell高级编程
linux bash shell脚本文件.sh,自动输入sudo的密码 在脚本中使用sudo命令,将密码保存在脚本中,不需要手动输入密码
主要是一份bash shell 4.2 的源码,共享给大家
Learning the bash Shell, 3rd Edition This refreshed edition serves as the most valuable guide yet to the bash shell. It's full of practical examples of shell commands and programs guaranteed to ...
Linux bash基本语法笔记Linux bash基本语法笔记Linux bash基本语法笔记Linux bash基本语法笔记Linux bash基本语法笔记Linux bash基本语法笔记
bash shell
学习Bash Shell的经典教材,推荐
主要讲的是Linux的BASH和Shell
Linux Bash Shell快速入门,编程这么轻松,学习兴趣方向最重要。
Bash Shell 编程高级教程 (中文版)
请注意: ... ... 一定要先下载完,再评论。如果先评论后下载,或者在下载的过程中评论,积分同样不会返还。...更多linux、ARM和C语言资源请参考: http://blog.csdn.net/arkofnoach/archive/2010/10/23/5960560.aspx