我知道以下代码会在/opt/hadoop/conf 目录中创建一个文件 core-site.xml。有人可以用 linux shell 术语为我分解它吗?特别是 << 运算符 & CORE_EOF?这些标记是如何工作的?我有点理解这一点,但想了解得更多。
cat >/opt/hadoop/conf/core-site.xml <<CORE_EOF
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:8020</value>
</property>
</configuration>
CORE_EOF
最佳答案
带有 << 运算符的命令将执行以下操作:
- 启动运算符左侧指定的程序,例如 cat。
- 抓取用户输入,包括换行符,直到在一行中满足运算符右侧指定的内容,例如 EOF
将读取到的除EOF值外的所有内容发送到左侧程序的标准输入。
cat << EOF Hello World EOF
会发送“你好”
世界”
到猫的标准输入。
这和这样做是一样的:
cat < file
文件包含:
Hello
World
关于linux - "<<"运算符如何在 linux shell 中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12168523/