我有一个具有这种格式的多行文件(反向 dns 条目):
251.2.168.192.in-addr.arpa core.admin.my.lan.
我正在尝试将该行分解为多个变量,以便我可以使用它们来重新创建其 IP 地址,并用作 IPA DNS 入口行
(
ipa dnsrecord-add admin.my.lan core --a-rec 192.168.2.251
)。
到目前为止,我已经能够想出这个:
while read line ; do
IFS=', ' read -r -a my_array <<< $(echo $line | awk -F '[. ]' '{print $4, $3, $2, $1, $7, $8}')
while IFS= read -r first second third fourth fifth sixth; do
echo "first=$first second=$second third=$third fourth=$fourth fifth=$fifth sixth=$sixth";
done <<< "$my_array"
unset my_array
done <reverse_entries.txt
但这只会创建第一个变量$first
:
first=192 second= third= fourth= fifth= sixth=
first=10 second= third= fourth= fifth= sixth=
first=192 second= third= fourth= fifth= sixth=
first=192 second= third= fourth= fifth= sixth=
first=192 second= third= fourth= fifth= sixth=
first=192 second= third= fourth= fifth= sixth=
first=192 second= third= fourth= fifth= sixth=
请问我做错了什么?