如何正确格式化主机文件-bash

ql3eal8s  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(423)

我想创造一个 Hadoop 集群,为了做到这一点,我必须格式化 /etc/hosts 文件只包含群集中节点的ip地址。现在看起来是这样的:

127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts

::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

## vagrant-hostmanager-start

<ipaddress1>   namenode
<ipaddress2>  secondarynamenode
<ipaddress3>  slave1
<ipaddress4>   slave2

## vagrant-hostmanager-end

最后,我只想把它当作


## vagrant-hostmanager-start

<ipaddress1>   namenode
<ipaddress2>  secondarynamenode
<ipaddress3>  slave1
<ipaddress4>   slave2

## vagrant-hostmanager-end

如何使用 sed , grep , cat 或任何 Bash 命令?

5ktev3wc

5ktev3wc1#

就像这样使用sed:

sed -n '/## vagrant-hostmanager-start/,/## vagrant-hostmanager-end/p' /etc/hosts

## vagrant-hostmanager-start

<ipaddress1>   namenode
<ipaddress2>  secondarynamenode
<ipaddress3>  slave1
<ipaddress4>   slave2

## vagrant-hostmanager-end

相关问题