linux - 我不清楚一个重定向运算符,那就是 <<

标签 linux shell redirect

<<的用法我不清楚,有人可以用一个简单的例子解释一下吗?真的很感激。

最佳答案

cat <<'EOF'
hello $$
I'm a here document that doesn't interpolate
any $-variables because of the qutoes around
the EOF marker
EOF

echo -------

cat <<EOF
hello $$
I'm a here document that does interpolate
EOF

echo -------

cat <<x
It doesn't matter what you use as the end of file marker
x

echo -------

cat <<'x'
Quotes prevent $-interpolation
x

输出:

hello $$
I'm a here document that doesn't interpolate
any $-variables because of the qutoes around
the EOF marker
-------
hello 29843
I'm a here document that does interpolate
-------
It doesn't matter what you use as the end of file marker
-------
Quotes prevent $-interpolation

关于linux - 我不清楚一个重定向运算符,那就是 <<,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38885511/

相关文章:

.htaccess 重定向子文件夹

powershell - 输出和简单的算法问题面向对象

linux - 引用其他 shell 文件的 shell 文件以及调用它们的最佳方式

linux - 在后台运行 linux 命令的同步问题

android - Ubuntu 16.04 : Android Emulator shows balck screen

shell - 使用 printf 指定宽度以生成干净的外观

c++ - 对于外部 API 的运行时跟踪,是否有比预处理器重定向更好的替代方法?

c - 将标准输出重定向到文件

linux - 使用 Qt(在 X11 上)检测窗口标题栏中的控制按钮位置

regex - 在 linux 和 AIX 中使用正则表达式替换 bash 脚本中的字符串