##/bin/bash
IP=($(grep -E -v "127.0.0.1|::" /etc/hosts | awk ‘{print $1}‘))
NAME=($(grep -E -v "127.0.0.1|::" /etc/hosts | awk ‘{print $2}‘))
Num=`grep -E -v "127.0.0.1|::" /etc/hosts|wc -l`
for i in $(seq $Num)
do
echo "${IP[i-1]}-${NAME[i-1]}"
done
时间: 2024-10-06 20:15:59