![](/img/trans.png)
[英]How does the “-newer $file” option of “find” command in linux shell work?
[英]How does “<<” operator work in linux shell?
我知道以下代码在/ 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
带有<<操作符的命令将执行以下操作:
将除EOF值以外的所有已读取内容发送到左侧程序的标准输入。
cat << EOF Hello World EOF
将发送“你好
世界”
到cat的标准输入。
与此操作相同:
cat < file
文件包含:
Hello
World
在这种情况下, 猫会创建一个新文件或用相同的名称重写旧文件
并将您的字符串放入文件中。
如果要将字符串添加到文件中,请输入以下内容:
猫>> /opt/hadoop/conf/core-site.xml << EOF
串
串
紧急行动
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.