可能重复:
Bash: How to Put Line Comment for a Multi-line Command
我想做这样的事情
sudo apt-get install \
#a very long description
#of the package
#that spans multiple lines
pkg1 \ #maybe I want an inline comment also
#another description that
#spans multiple lines
pkg2
请注意,我不仅对apt-get
命令感兴趣。
答案 0 :(得分:75)
据我所知,Bash在单个命令中忽略了'#'之后的所有内容,而且多线程不会改变它。但是,您可以使用bash数组实现相同级别的表达式:
packagelist=(
package1 # Inline Comments
# Multiline Comments too
package2
# Package description goes here
# Detailed descriptions..
)
sudo apt-get install ${packagelist[@]}