如何在Shell脚本中注释多行命令?

用户名

调用长而繁琐的命令时,最好将它们写在shell脚本中。有没有简单的方法可以在此类脚本中注释行?我尝试了以下方法,但均无济于事。

# the \ is also commented out, resulting in "command" and "--good-switch".
command \
  #--bad-switch \
  --good-switch \

# seems to send an extra argument to the command
command \
  \ #--bad-switch \
  --good-switch
格伦·杰克曼

这可能是一个选择:将命令和args存储在数组中,然后在执行后执行

# build the command
cmd=( ls
        -F
      # -a   # comment out this option temporarily
        -l
    )
# $cmd is now an array with 3 elements

# execute it
"${cmd[@]}"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章