首页 > 开发 > Linux Shell > 正文

shell对比文件内容脚本分享

2020-07-27 19:18:06
字体:
来源:转载
供稿:网友

复制代码 代码如下:

#!/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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表