shell编程——保留元字符

时间:2023-03-09 03:27:40
shell编程——保留元字符

在shell中有以下几种字符含有特殊含义,属于保留元字符:

& * + ^ $ ` " | ?

当脚本在执行过程中遇到上述字符时,会执行其具有的特殊含义,除非在前面加“\”屏蔽其特殊含义

[root@localhost ~]# sed -n '/$/p' test.sh
#!/bin/bash
/root/collect/
65432
第三行 34567&x
第四行 45678$a
第五行 56789%c
[root@localhost ~]# sed -n '/\$/p' test.sh
第四行 45678$a