我想嵌入这样的评论
ls -l \
-a \
# comment here
-h \
-t .
但似乎这是不可能的。也许确实存在其他变体?将评论紧跟在反斜杠之后或以反斜杠结束评论都没有帮助。
最佳答案
上面的帖子没有直接的解决方案。然而,在更早的帖子中实际上提到了一个直接的解决方案:How to put a line comment for a multi-line command和 Commenting in a Bash script .
我最喜欢的解决方案是:
ls -l `# long format` \
-a `# all files` \
-h `# human readable` \
-t `# time sort`
您将需要重音符号 (`) 引号和八角符号 (#) 来表示注释。在反斜杠前使用它们。
关于bash - 当用反斜杠分割行时是否可以使用注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23591273/