您可以在此处的带有标签的文档内缩排文本,需要使用<<-重定向运算符而不是<<:
$ 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.
这样的一个实际用例(如所述man bash)在shell脚本中,例如:
if cond; then cat <<- EOF hello there EOF fi
通常,如本if语句所述,在代码块内缩进行,以提高可读性。没有<<-运算符语法,我们将被迫编写上述代码,如下所示:
if cond; then cat << EOF hello there EOF fi
读起来很不愉快,而且在更复杂的现实脚本中情况变得更糟。