我有一个非常长的configuration文件几乎没有评论和取消注释行现在,我想要打印出行取消注释
# LOCAL PATHNAME INFORMATION # # The queue_directory specifies the location of the Postfix queue. # This is also the root directory of Postfix daemons that run chrooted. # See the files in examples/chroot-setup for setting up Postfix chroot # environments on different UNIX systems. # queue_directory = /var/spool/postfix # The command_directory parameter specifies the location of all # postXXX commands. # command_directory = /usr/sbin
我想输出是没有评论的行
queue_directory = / var / spool / postfix
command_directory = / usr / sbin
egrep -a -v '^[[:space:]]*#' config_file | egrep -a '[[:print:]]' | less
将在#之前占据空格。 pipe到less,你可以轻松地查看它
用$ 1replaceconfig_file,并把行放在/ usr / local / bin / cless中,然后chmod it + x,当你需要的时候,你有一个很好的小脚本。
cless config_file
假设注释行以“#”开头:
grep -v '^#' config_file
将在文件“config_file”中打印所有不以“#”开头的行。