在谈到bash脚本 [英] Commenting in BASH script

查看:94
本文介绍了在谈到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}

如果我尝试并添加注释说的猫$ {}的mysqldump | \\ #Output mysqldump的文件

If I try and add a comment say "cat ${MYSQLDUMP} | \ #Output MYSQLDUMP File"

我得到的 #DELETE:找不到的?
是否有可能在这里或不作评论,因为| \\

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天全站免登陆