Shell脚本案例
检查脚本
修复脚本
#!/bin/bash
#Num_passmin=`cat /etc/login.defs | grep -n ^PASS_MIN_DAYS | awk -F[:] '{print $1}'`
Num_passmin=`sed -n /^"PASS_MIN_DAYS"/= /etc/login.defs`
if [ -n "$Num_passmin" ];then
Count_passmin=1
for a in $Num_passmin
do
if [ $Count_passmin == 1 ];then
sed -i $a'c PASS_MIN_DAYS 2' /etc/login.defs
else
sed -i $a'c \#PASS_MIN_DAYS 重复配置已替换' /etc/login.defs
fi
Count_passmin=$Count_passmin+1
done
else
echo "PASS_MIN_DAYS 2" >> /etc/login.defs
fi