Bash 在此处缩排文档
示例
您可以在此处的带有标签的文档内缩排文本,需要使用<<-重定向运算符而不是<<:
$ cat <<- EOF
This is some content indented with tabs `\t`.
You cannot indent with spaces you __have__ to use tabs.
Bash will remove empty space before these lines.
__Note__: Be sure to replace spaces with tabs when copying this example.
EOF
This is some content indented with tabs _\t_.
You cannot indent with spaces you __have__ to use tabs.
Bash will remove empty space before these lines.
__Note__: Be sure to replace spaces with tabs when copying this example.这样的一个实际用例(如所述manbash)在shell脚本中,例如:
if cond; then
cat <<- EOF
hello
there
EOF
fi通常,如本if语句所述,在代码块内缩进行,以提高可读性。没有<<-运算符语法,我们将被迫编写上述代码,如下所示:
if cond; then
cat << EOF
hello
there
EOF
fi读起来很不愉快,而且在更复杂的现实脚本中情况变得更糟。
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短