Linux配置文件中的#(井号)和;(分号)的区别?
原文: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.翻译
·
在看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 = SAMBA
security = user
; passdb backend = tdbsam
; printing = cups
printcap name = cups
; load printers = yes
cups 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 "^$"
更多推荐



所有评论(0)