Linux bash script HereDoc All In One
Linux bash script HereDoc All In One
Linux shell script
multi-lines comments/ Linux shell scriptblock comments
Linux shell 脚本多行注释/Linux shell 脚本块注释
HereDoc
EOF
# 这个是单行注释
# EOF 多行注释
<<EOF
Linux Here Documents / Here Doc
这个是多行注释 1
这个是多行注释 2
这个是多行注释 3
EOF

# EOF 多行注释, command
echo <<EOF
Linux Here Documents / Here Doc
这个是多行注释 1
这个是多行注释 2
这个是多行注释 3
EOF
# EOF 多行注释, command
cat <<EOF
Linux Here Documents / Here Doc
这个是多行注释 1
这个是多行注释 2
这个是多行注释 3
EOF
Bash HereDoc Syntax
[COMMAND] <<[-] 'DELIMITER'
Line 1
Line 2
...
DELIMITER
COMMANDis optional. Works for any command that acceptsredirection.<<is theredirection operatorforforwardinga HereDoc to the COMMAND.-is a parameter for tab suppression.DELIMITERin thefirst linedefines a HereDocdelimiter token. END, EOT, andEOFare most common, but any multicharacter word that won't appear in the body works.Omit single quoteson the first line to allow command and variable expansion.- The DELIMITER in the
last lineindicates the end of a HereDoc. Use the same word from the first linewithouttheleading whitespaces.
The HereDoc itself contains any number of lines with strings, variables, commands, and other inputs.
Bash HereDoc 语法
[命令] <<[-] '分隔符标记'
Line 1
Line 2
...
分隔符标记
命令是可选的。适用于任何接受重定向的命令。<<是用于将 HereDoc 转发到 COMMAND 的重定向运算符。-是制表符抑制的参数。第一行中的 DELIMITER 定义了 HereDoc分隔符标记。 END、EOT 和EOF是最常见的,但任何不会出现在正文中的多字符词都可以使用。在第一行省略单引号以允许命令和变量扩展。最后一行中的 DELIMITER 表示 HereDoc 的结尾。使用第一行中没有前导空格的相同单词。
Here documents & Here strings
https://bash.cyberciti.biz/guide/Here_documents
https://bash.cyberciti.biz/guide/Here_strings
demos
echo -evsprintf
#!/usr/bin/env bash
# linux block comments / linux multi-lines comments
cat <<EOF
Linux Here Documents
这个多行注释 1
这个多行注释 2
这个多行注释 3
EOF
# echo \\n
echo -e '\n'
echo '$0'=$0
echo '$1'=$1
# echo -e '\n'
printf '\n'
var1="Hello"
var2="World"
cat <<EOF
Linux Here Documents
$var1
$var2
EOF
# echo <<EOF
# Linux Here Documents
# 这个多行注释 1
# 这个多行注释 2
# 这个多行注释 3
# EOF

#!/usr/bin/env bash
echo "auto create templates in current folder..."
echo $0
echo $1
# auto create templates in current folder...
# ./auto-ts-files-generator.sh
# 10
# linux block comments / linux multi-lines comments
<<EOF
Linux Here Documents
这个是多行注释 1
这个是多行注释 2
这个是多行注释 3
EOF
# TODO:
# 1. 接收参数 ✅
# 2. 读取模版
# 3. NPM publish
(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!
refs
EOF
https://www.cnblogs.com/xgqfrms/tag/EOF/
https://phoenixnap.com/kb/bash-heredoc
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04
echo -e
https://www.cnblogs.com/xgqfrms/tag/echo/
printf
https://www.cnblogs.com/xgqfrms/tag/printf/
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/17250153.html
未经授权禁止转载,违者必究!

浙公网安备 33010602011771号