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 教师闺蜜祝福语简短