gpt4 book ai didi

bash - Bash 的内联注释?

转载 作者:行者123 更新时间:2023-11-29 08:38:26 27 4
gpt4 key购买 nike

我希望能够在单行命令中注释掉单个标志。 Bash 似乎只有 from # till end-of-line 注释。我在看像这样的技巧:

ls -l $([ ] && -F is turned off) -a /etc

虽然丑陋,但聊胜于无。有没有更好的办法?

以下似乎可行,但我不确定它是否可移植:

ls -l `# -F is turned off` -a /etc

最佳答案

我的首选是:

Commenting in a Bash script

This will have some overhead, but technically it does answer your question

echo abc `#put your comment here` \
def `#another chance for a comment` \
xyz etc

And for pipelines specifically, there is a cleaner solution with no overhead

echo abc |        # normal comment OK here
tr a-z A-Z | # another normal comment OK here
sort | # the pipelines are automatically continued
uniq # final comment

How to put a line comment for a multi-line command

关于bash - Bash 的内联注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2524367/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com