注意:linux通配符和三剑客(grep,awk,sed)正则表达式是不一样的,因此,代表的意义也是有较大区别
通配符一般用户命令行bash环境,而linux正则表达式用于grep,sed,awk场景。
| #管道符,或者(正则)
> 或1> #输出重定向,覆盖原有数据
>> #输出追加重定向,追加内容到文件尾部
< #输入重定向(xargs,tr)
<< #追加输入重定向
~ #当前用户家目录``
- #上一次所在的路径
$() #引用命令被执行后的结果
$ #以。。。结尾(正则)
/ #路径分割符,也是根的意思
^ #以。。。开头(正则)
* #匹配全部字符,通配符
? #任意一个字符,通配符#
; #连续不同命令的分隔符
# 配置文件注释
‘’ #单引号不具有变量置换功能,输出时所见即所得
“” #双引号具有变量置换功能,解析变量后输出,不加引号相当于双引号。
`` #反引号两个``中间为命令,会先执行,等同于$()
! #逻辑运算中的“非”(not)
& #让程序或脚本切换到后台执行
&& #并且 同时成立,当前一个指令执行成功时,执行后一个指令
|| #or 或者,当前一个指令执行失败时,执行后一个指令
[] #表示一个范围(正则,通配符)
{} #产生一个序列(通配符)
. #当前目录
.. #上级目录
- *号举例:
[root@centos6 test]# ls
ceshi.sh shiyan.sh test.sh
[root@centos6 test]# ls *.sh
ceshi.sh shiyan.sh test.sh
[root@centos6 test]# touch ceshi.txt
[root@centos6 test]# ls *
ceshi.sh ceshi.txt shiyan.sh test.sh
- ?号举例:
[root@centos6 test]# ls ?.sh
ls: cannot access ?.sh: No such file or directory
[root@centos6 test]# ls ????.sh
test.sh
- ;号举例:
[root@centos6 test]# pwd;pwd
/root/cheshi/test
/root/cheshi/test
- {}内容序列举例:
[root@centos6 test]# echo ceshi-{b..z}
ceshi-b ceshi-c ceshi-d ceshi-e ceshi-f ceshi-g ceshi-h ceshi-i ceshi-j ceshi-k ceshi-l ceshi-m ceshi-n ceshi-o ceshi-p ceshi-q ceshi-r ceshi-s ceshi-t ceshi-u ceshi-v ceshi-w ceshi-x ceshi-y ceshi-z
[root@centos6 test]# cp a.txt{,.bak}