Linux bash write long string with multi-lines comments All In One
Linux bash write long string with multi-lines comments All In One
linux shell
block comments
/ linux shellmulti lines comments
https://stackoverflow.com/a/76127090/5934465
Here documents
& Here strings
https://bash.cyberciti.biz/guide/Here_documents
https://bash.cyberciti.biz/guide/Here_strings
demos
string variable
MARKDOWN='
{
"msgtype": "markdown",
"markdown": {
"content": "⏰ '$SH_DATE'\n\n🎉<font color=\"warning\">读书会快捷链接</font>\n\n📘[<font color=\"info\">阅读打卡链接</font>](https://library.xgqfrms.xyz/#/club/share)\n\n👨🏻💻[<font color=\"info\">我的链接</font>](https://library.xgqfrms.xyz/#/my)\n\n💰[<font color=\"info\">积分链接</font>](https://library.xgqfrms.xyz/#/mall)\n\n<font color=\"warning\">读书会机器人🤖️ features:</font>\n\n<font color=\"comment\">1. 大大简化进入打卡的流程,跳过 3s 首页的推荐;</font>\n\n<font color=\"comment\">2. 每天早晚两次打卡提醒(08:00 和 20:00) ⏰,降低忘记打卡的风险;</font>\n\n",
"mentioned_list":["Eric"],
}
}'
Here Documents
Here Doc
EOF and END are often chosen as the MyUniqueLimitString but any string can be used as long as it does not appear within the here document text.
EOF
和 END
通常被选为 MyUniqueLimitString,但可以使用任何字符串,只要它没有出现在此处文档文本中即可。
#!/bin/bash
cat <<End-of-text
--------------------------
The quick brown fox
jumped over the lazy dog
--------------------------
End-of-text
#!/bin/bash
ACTION="Quickly"
cat <<End-of-txt
The quick brown fox $ACTION
jumped over the lazy dog
End-of-txt
#!/bin/bash
DB_NAME="db064"
PASSWORD="Pa$$w0rd"
APP_USER="user64"
APP_PASSWORD="cfE7JcEbgzW1XUUaEQ"
mysql -u root --password="${PASSWORD}" <<EOF
CREATE DATABASE ${DB_NAME};
CREATE USER '${APP_USER}'@'localhost' IDENTIFIED BY '${APP_PASSWORD}';
GRANT ALL ON ${DB_NAME}.* TO '${APP_USER}'@'localhost'
EOF
https://ss64.com/bash/syntax-here.html
https://en.wikipedia.org/wiki/Here_document
https://tldp.org/LDP/abs/html/here-docs.html
https://linuxhint.com/bash-heredoc-tutorial/
solutions
# EOF
<<EOF
Linux Here Documents
这个多行注释 1
这个多行注释 2
这个多行注释 3
EOF
# END
<<END
Linux Here Documents
这个多行注释 1
这个多行注释 2
这个多行注释 3
END
# EOL
<<EOL
Linux Here Documents
这个多行注释 1
这个多行注释 2
这个多行注释 3
EOL
# EOM
<<EOM
Linux Here Documents
这个多行注释 1
这个多行注释 2
这个多行注释 3
EOM
js template string
const markdown = `
⏰ '$SH_DATE'\n\n
🎉<font color=\"warning\">读书会快捷链接</font>\n\n
📘[<font color=\"info\">阅读打卡链接</font>](https://library.xgqfrms.xyz/#/club/share)\n\n
👨🏻💻[<font color=\"info\">我的链接</font>](https://library.xgqfrms.xyz/#/my)\n\n
💰[<font color=\"info\">积分链接</font>](https://library.xgqfrms.xyz/#/mall)\n\n
<font color=\"warning\">读书会机器人🤖️ features:</font>\n\n
<font color=\"comment\">1. 大大简化进入打卡的流程,跳过 3s 首页的推荐;</font>\n\n
<font color=\"comment\">2. 每天早晚两次打卡提醒(08:00 和 20:00) ⏰,降低忘记打卡的风险;</font>\n\n",
`;
Linux bash script HereDoc
All In One
Linux shell script multi-lines comments
/ Linux shell script block comments
Linux shell 脚本多行注释
/Linux shell 脚本块注释
https://www.cnblogs.com/xgqfrms/p/17250153.html
refs
https://stackoverflow.com/questions/7316107/how-to-split-strings-over-multiple-lines-in-bash
https://serverfault.com/questions/72476/clean-way-to-write-complex-multi-line-string-to-a-variable
https://www.geeksforgeeks.org/multi-line-comment-in-shell-script/
https://unix.stackexchange.com/questions/157328/how-can-i-remove-all-comments-from-a-file
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/15697376.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2020-12-16 互联网网络用语缩略语查询网站 All In One
2020-12-16 vue 的 computed 属性在什么时间执行
2020-12-16 vue v-on-clickaway
2020-12-16 vuex 3.x All In One
2020-12-16 vue 自动注册全局组件
2019-12-16 script async / defer
2019-12-16 Chrome Dark Theme