#!/bin/sh
for file1 in directorypath/*
do
for file2 in directorypath/*
do
if [ "$file1" = "$file2" ]; then
echo "files are same"
else
cp /dev/null /home/temp.txt
grep -f $file1 $file2 > /home/common.txt
grep -v -x -f /home/common.txt $file1 > /home/temp.txt
cp /dev/null $file1
cat /home/temp.txt >> $file1
cp /dev/null /home/temp.txt
grep -v -x -f /home/common.txt $file2 > /home/temp.txt
cp /dev/null $file2
cat /home/temp.txt >> $file2
fi;
done
done
This code is working fine for files of small size. Since I have big text files to process, this code is taking too much time even on server machine. Please help! How do I achieve the same efficiently? Thanks in advance.