I know the following code creates a file core-site.xml in the /opt/hadoop/conf directory. Can some one please break it down in linux shell terms for me? Especially the << operator & CORE_EOF? How does those markers work? I kind of understand this but wanted to know better.
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
A command with the << operator will do the following things :
Send all that have been read except the EOF value to the standard input of the program on the left.
cat << EOF Hello World EOF
Will send "Hello
World"
To the standard input of cat.
It is the same as doing this:
cat < file
With file containing :
Hello
World
Cat make a new file or rewrite old with same name in this condition
and put your string into file.
When you want to add strings into file type this:
cat >> /opt/hadoop/conf/core-site.xml << EOF
String
String
EOF
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.