2011. 9. 3. 22:14

파일 비교 스크립트 8


최종 버전 파일 비교 스크립트 
어느 txt 파일이든 사이즈의 크기는 상관없음.
a.txt 와 b.txt 에 담긴 내용을 sort 하여 비교 


파일 비교 스크립트

(1) comm -12 a.txt b.txt
양쪽 모두에 존재

(2) comm -23 a.txt b.txt
a_only.txt

(3) comm -13 a.txt b.txt
b_only.txt


#!/bin/bash


### sort stage 

sort -u a.txt > imsy 

cat imsy > a.txt

sort -u b.txt > imsy

cat imsy > b.txt


### compare stage 

comm -12 a.txt b.txt > duble.txt

comm -23 a.txt b.txt > a_only.txt

comm -13 a.txt b.txt > b_only.txt


### Result stage 


echo "################################"

echo " a_only.txt is existed in a.txt"

echo "################################"


echo "################################"

echo " b_only.txt is existed in b.txt"

echo "################################"


echo "#########################################"

echo " double.txt is existed in a.txt & b.txt"

echo "#########################################"