日期:2014-05-16  浏览次数:20574 次

linux文件比对的问题
文件a,b。想得到在文件a中,但是不在文件b中的数据。
文件内容是每行一个邮箱。

------解决方案--------------------
Assembly code

#!/bin/bash

cat $1 | while read line
do
    cat $2 | grep -q $line
    if [  ! $? -eq 0 ]; then
        echo $line
    fi
done

------解决方案--------------------
sort a > a.tmp
sort b > b.tmp
comm -23 a.tmp b.tmp