文件名称:add_policy.sh
内容:
#!/bin/bash main(){ num=1 echo "<?xml version="1.0" encoding="utf-8"?> <direct> </direct> " > direct.xml # read -p "请输入文件全路径名称:" ip_addr while read line do policy="<rule priority=$num table="filter" ipv="ipv4" chain="OUTPUT">-d $line -j ACCEPT</rule>" echo $policy sed -i "/<\/direct>/i ${policy}" direct.xml num=$(( $num + 1 )) done < $1 } if [ $(echo $#) = 1 ] then main $1 else echo "使用方法add_policy 跟上文件:address.txt" fi
标签:xml,--,direct,echo,num,出站,linux,policy From: https://www.cnblogs.com/yeziwinone/p/17602498.html