我想在下面的脚本中添加另一个八位字节(192.168.x.i):
IPPFX=$1
for i in `seq 1 255` ; do LIST="$LIST ${IPPFX}.$i" ; done
for i in $LIST ; do
ENTRY="`host $i`"
[ $? -ne 0 ] && continue
ENTRY=`echo "$ENTRY" l sed -e 's/.* //' -e 's/.$//'`
echo -e "$it$ENTRY"
done
我试着添加
IPPFX=$1
for i in `seq 1 255` ;
for j in `seq 1 255` do LIST="$LIST
${IPPFX}.$j.$i" ; done
for i in $LIST ;
for j in $LIST ; do
ENTRY="`host $j.$i`"
[ $? -ne 0 ] && continue
ENTRY=`echo "$ENTRY" l sed -e 's/.* //' -e 's/.$//'`
echo -e "$j$it$ENTRY"
done
也许你想要这样的东西:
#!/bin/bash
ippfx=$1
for ip in "$ippfx".{0..255}.{0..255}; do
entry=$(host "$ip" | sed 's/.* //; s/.$//') || continue
printf '%st%sn' "$ip" "${entry//$'n'/ }"
done
像
这样调用脚本./tst 216.58
有两个八位元。