我们的git存储库中有几个带注释的标签.较旧的标签有伪造的消息,我们想要更新为我们的新风格.
% git tag -n1
v1.0 message
v1.1 message
v1.2 message
v2.0 Version 2.0 built on 15 October 2011.
Run Code Online (Sandbox Code Playgroud)
在此示例中,我们希望使v1.x消息看起来像v2.0消息.有谁知道我们会怎么做?
如何从脚本中评论以下几行的每一行?
cat ${MYSQLDUMP} | \
sed '1d' | \
tr ",;" "\n" | \
sed -e 's/[asbi]:[0-9]*[:]*//g' -e '/^[{}]/d' -e 's/""//g' -e '/^"{/d' | \
sed -n -e '/^"/p' -e '/^print_value$/,/^option_id$/p' | \
sed -e '/^option_id/d' -e '/^print_value/d' -e 's/^"\(.*\)"$/\1/' | \
tr "\n" "," | \
sed -e 's/,\([0-9]*-[0-9]*-[0-9]*\)/\n\1/g' -e 's/,$//' | \
sed -e 's/^/"/g' -e 's/$/"/g' -e 's/,/","/g' >> ${CSV}
Run Code Online (Sandbox Code Playgroud)
如果我尝试添加评论说" cat $ {MYSQLDUMP} |\#Output MYSQLDUMP File ",我得到:
删除:未找到
是否有可能在这里发表评论,因为" __CODE__"?
我希望能够在一行命令中注释掉一个标志.Bash似乎只有from # till end-of-line评论.我正在看这样的技巧:
ls -l $([ ] && -F is turned off) -a /etc
Run Code Online (Sandbox Code Playgroud)
它很难看,但总比没有好.有没有更好的办法?
以下似乎有效,但我不确定它是否可移植:
ls -l `# -F is turned off` -a /etc
Run Code Online (Sandbox Code Playgroud) 可能重复:
Bash:如何为多行命令添加行注释
我想做这样的事情
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
Run Code Online (Sandbox Code Playgroud)
请注意,我不仅对apt-get命令感兴趣.
我在shell脚本中调用了很长的参数列表:
foo-command \
--important-argument $ONE \
--indispensable-flag $ENABLED \
--an-optional-toggle "will probably be commented out some day" \
$ARGUMENTS \
$MORE_ARGUMENTS
Run Code Online (Sandbox Code Playgroud)
我不能在这个多行电话中插入评论,可以吗?
例如,让我们说,我该如何评论该--an-optional-toggle线?
我怎么能# in sorted order在之后添加评论$ARGUMENTS?
无论我尝试什么,octothorp #符号阴影线延续反斜杠\,反之亦然.有什么建议吗?
我想像这样嵌入评论
ls -l \
-a \
# comment here
-h \
-t .
Run Code Online (Sandbox Code Playgroud)
但这似乎是不可能的。也许存在其他变体?将评论放在反斜杠之后或以反斜杠结束评论无济于事。
我想评论bash for循环参数列表的部分内容.我想写这样的东西,但我无法打破多行的循环.使用\似乎也不起作用.
for i in
arg1 arg2 # Handle library
other1 other2 # Handle binary
win1 win2 # Special windows things
do .... done;
Run Code Online (Sandbox Code Playgroud) 我知道我可以在 bash 中使用分隔长命令\- 有没有办法编写内联注释?
例如,类似于:
wget \
# Needed to get to end of around 100 pages of results
--level=0 \
# Save into downloads directory
--directory=downloads \
--recursive \
# Normally wget won't span hosts, and .example.com use a CDN
--span-hosts --domains='assets.publishing.example.com,www.example.com' \
# Only care about links matching this regex
--accept-regex 'assets|swag' --regex-type pcre
# The site we actually want to scrape
'https://www.example.com/swag'
Run Code Online (Sandbox Code Playgroud)
如果可以使用zsh pwsh或类似,我也很感兴趣。