在BASH脚本中注释 [英] Commenting in BASH script

查看:143
本文介绍了在BASH脚本中注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何对脚本中以下行的每一行进行注释:

How can I comment on each line of the following lines from a script:

   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}

如果我尝试添加注释说 cat $ {MYSQLDUMP} | \ #Output MYSQLDUMP文件

我得到 #Delete:not found
这里可以注释或不是因为| \

I get "#Delete: not found" ? Is it possible to comment here or not because of " | \ "

推荐答案

但在技术上它确实回答了你的问题

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 clean 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

如何为多行命令放置行注释

这篇关于在BASH脚本中注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆