Linux配置文件中的#(井号)和;(分号)的区别?

        在看Linux配置文件时,发现有#(井号)和;(分号)注释,甚是困惑。经查找有一段E文给出解释,特翻译一下,希望能帮助到码友。

  • 原文:

Any line which starts with a ;(semi-colon) or a #(hash) is a comment and is ignored. 
In this example we will use a # for commentry and a ; for parts of the config file that you may wish to enable.

  • 翻译:

任何以;(分号)或#(#号)开头的行表示一个注释,并被忽略。
在本例中,我们将使用一个#(#号)表示备注,对于配置文件可能会启用的部分使用;(分号)

cat /etc/samba/smb.conf# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.[global]workgroup = SAMBAsecurity = user;	passdb backend = tdbsam;	printing = cupsprintcap name = cups
;	load printers = yescups options = raw

如何在查看配置文件更简洁地显示:

  • 隐藏以#开头的注释行
grep -Pv "(^#)|(^\t#)" /etc/samba/smb.conf.example  | grep -v "^$"
  • 隐藏以;开头的注释行
grep -Pv "(^;)" /etc/samba/smb.conf.example  | grep -v "^$"
  • 隐藏所有注释行
grep -Pv "(^#)|(^\t#)|(^;)" /etc/samba/smb.conf.example  | grep -v "^$"


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部