代码改变世界

小知识:grep过滤以#号开头的注释行 和 空行

2023-06-30 01:57  AlfredZhao  阅读(662)  评论(0编辑  收藏  举报

xtts的配置文件,有很多注释不想直接去掉的情况下,想清楚的看到目前设置了哪些参数,可以用grep过滤查看:
grep -vE '^#|^$' xtt.properties

效果如下:

[oracle@db11gcas xtt]$ grep -vE '^#|^$' xtt.properties
tablespaces=DBS_D_JINGYU, DBS_I_JINGYU
platformid=13
src_scratch_location=/u01/media/src_backups/
dest_datafile_location=+DATADG
dest_scratch_location=/xtts/
parallel=3
rollparallel=2
getfileparallel=4
destconnstr=sys/oracle@jingyu
allowstandby=1

简单来说,E是正则,v是反向匹配,^$ 是空行,^#是#开头的:

-E, --extended-regexp
Interpret PATTERN as an extended regular expression (ERE, see below). (-E is specified by POSIX.)

-v, --invert-match
Invert the sense of matching, to select non-matching lines. (-v is specified by POSIX.)

Anchoring
The caret ^ and the dollar sign $ are meta-characters that respectively match the empty string at the beginning and end of a line.