内核参数比较

使用sysctl -a > file1.log
取出系统的内核参数,拷贝到同一个目录下面
然后用下面的脚本打印出不同的值
然后分析差异
diff只能按行比较,而这个文件有错行,所以用一个简单的办法实现

#! /bin/sh
# the output is the different from file1 to file2 ,so you must change the position of the file1name of file1 and file2 ;
file1=centos.log
file2=centos2.log

for key in `cat $file1 |awk '{print $1}'`
do
va1=`cat $file1 |grep $key|cut -f 2 -d "="`
va2=`cat $file2 |grep $key|cut -f 2 -d "="`

if [ "$va1" != "$va2" ];then

echo $key
echo "$file1":$va1
echo "$file2":$va2
echo ======================
fi
done