本文主要是介绍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 "^$"
这篇关于Linux配置文件中的#(井号)和;(分号)的区别?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!