欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

shell对比文件内容脚本分享

程序员文章站 2023-11-25 13:19:34
复制代码 代码如下:#!/bin/shfunction _diffab(){x=0for i in `cat $1`;do    &...

复制代码 代码如下:

#!/bin/sh
function _diffab(){
x=0
for i in `cat $1`;do
        for j in `cat $2`;do
                if [ $i == $j ];then
                        x=1
                        break;
                fi
        done
                if [ $x -ne 1 ];then
                        echo $i
                fi
        x=0
done
}


if [ "$1" == "" ] || [ "$2" == "" ];then
echo "use like this: $0 filea fileb"
else
{
_diffab $1 $2
_diffab $2 $1
}
fi