删除文档关键字行以及下面N行

#!/bin/sh
awk=/bin/awk
sed=/bin/sed
today=$(date +"%Y%m%e")
if [ "$#" -ne "2" ];then
echo "must two variable!";
exit 1
fi
a=$(cat /etc/dhcp/dhcpd.conf | awk '{print NR" "$0}'|grep $1|awk '{print $1}')
b=$(($a+3))
if [ "$a" = "" ];then
echo "no exist $1 vps"
exit 2
fi
mv -f /vm/$1 /vm/$1.${today}.drop
/root/deleteftp.sh $1 $2
rm -rf /var/lib/vnstat/$1
rm -rf /var/lib/vnstat/vnstat_dump_$1
cp -f /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.confbak
sed ''${a}','${b}'d' /etc/dhcp/dhcpd.conf > /etc/dhcp/dhcpd.confzzh
mv -f /etc/dhcp/dhcpd.confzzh /etc/dhcp/dhcpd.conf
service dhcpd reload

你可能感兴趣的:(删除文档关键字行以及下面N行)