shell 从文件获取数据并赋值给变量
# cat ip.sh#!/bin/sh
wan0='eth0'
FILE='/home/huwei/ip.txt'
while read i
do
a=$(echo "$i"|awk -F ' ' '{print $1}')
b=$(echo "$i"|awk -F ' ' '{print $2}')
#此处显示变量的值,其实可以省略
echo "$a"
echo "$b"
iptables -A INPUT -s $a-i $wan0 -p tcp --dport $b -j ACCEPT
/etc/init.d/iptables save
done
页:
[1]