我想要嵌入这样的评论
ls -l \
-a \
# comment here
-h \
-t .
但这似乎是不可能的。也许确实存在一些其他的变体?将注释放在反斜杠后面或以反斜杠结束注释都无济于事。
发布于 2018-10-25 03:49:45
上面的帖子没有直接的解决方案。然而,有一种直接的解决方案,实际上在更老的帖子中也提到过: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`
您需要同时使用重音引号(`)和八分音符(#)来表示注释。在反斜杠之前使用它们。
发布于 2014-11-29 05:40:55
你可以用一个不需要连续字符的数组来做这样的事情:
ls_cmd=(
ls
-l # long form
-a # show hidden files
-h # human-readable sizes
-t # sort by time
.
)
"${ls_cmd[@]}" # run the command from the array
...but对于一般情况,答案是否定的。
发布于 2014-05-12 02:37:46
在这种情况下,我通常会这样做
ls -l -a -h -t .
# | | | time sort
# | | human readable
# | all files
# long format
或者当它们存在时,我使用长形式的参数,例如--human-readable
而不是-h
。
https://stackoverflow.com/questions/23591273
复制相似问题