我有一个很长的配置文件,几乎没有注释和取消注释行现在我想打印出取消注释的行
# 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
假设注释行在第一个位置以“#”开头:
将打印文件“config_file”中所有不以“#”开头的行。
将占 # 之前的空格。管它少,你可以很容易地查看它
用 $1 替换 config_file 并将该行放入 /usr/local/bin/cless 并 chmod it +x ,您可以在需要时使用漂亮的小脚本。