Difference of all files

cat /home/prabhucloudxlab/prabhu2/input2.txt
Hai this is hari
Hai this is hari
Hai this is hari
Hai this is hari
I am looking for an ETL / Hadoop / Big Data /DWH Testing profile job..
Please let me know if you have any openings regarding ETL / Hadoop / Big Data / DWH Tester.


cat /home/prabhucloudxlab/prabhu/input2.txt
Hai this is prabhu
Hai this is manyam
Hai this is prabhu
Hai this is taraka
I am looking for an ETL / Hadoop / Big Data /DWH Testing profile job..
Please let me know if you have any openings regarding ETL / Hadoop / Big Data / DWH Tester.

cat /home/prabhucloudxlab/prabhu2/input.txt
Hai this is prabhu
Hai this is manyam
Hai this is prabhu
Hai this is taraka
I am looking for an ETL / Hadoop / Big Data /DWH Testing profile job..
Please let me know if you have any openings regarding ETL / Hadoop / Big Data / DWH Tester.


cat /home/prabhucloudxlab/prabhu/input.txt
Hai this is hari
Hai this is hari
Hai this is hari
Hai this is hari
I am looking for an ETL / Hadoop / Big Data /DWH Testing profile job..
Please let me know if you have any openings regarding ETL / Hadoop / Big Data / DWH Tester. 


===================================================================================================================================



#Script

#! bin/bash
#---------------->> 1st method

echo "enter file_name1:"
read file_name1
echo "enter file_name2:"
read file_name2
echo  -e "difference is :\n" $(diff $file_name1 $file_name2 | grep '^>' | sed 's/^>\ //')
echo " "
echo " "
echo " "
echo "================================================================================="


#---------------->> 2nd method

# command arguments can be accessed as
echo "Total Files:" $#
echo "All Files values are:" $@
txt_file1=$1
txt_file2=$2
echo -e "difference is : \n" $(diff $txt_file1 $txt_file2 | grep '^>' | sed 's/^>\ //')
echo " "
echo " "
echo " "
echo "================================================================================="


#---------------->> 3rd method

diff1="$(diff /home/adimulamvenkat19851609/prabhu/input.txt /home/adimulamvenkat19851609/prabhu2/input.txt | grep '^>' | sed 's/^>\ //')"
echo -e "difference files are: \n" $diff1
echo " "
echo " "
echo " "
echo "================================================================================="



#---------------->> 4th method

ls /home/prabhucloudxlab/prabhu/*.txt>file_names1.txt
ls /home/prabhucloudxlab/prabhu2/*.txt>file_names2.txt
file_name1="$(<file_names1.txt)"
file_name2="$(<file_names2.txt)"
for file1 in $file_name1;
do
        for file2 in $file_name2
        do
        echo " the files name are:" $file1 and $file2
        diff $file1 $file2 | grep '^>' | sed 's/^>\ //'
        done
done



Output:

[prabhucloudxlab@cxln4 ~]$ sh diff.sh /home/prabhucloudxlab/prabhu/input2.txt /home/prabhucloudxlab/prabhu2/input2.txt

enter file_name1:
/home/prabhucloudxlab/prabhu/input2.txt
enter file_name2:
/home/prabhucloudxlab/prabhu2/input2.txt
difference is :
 Hai this is hari Hai this is hari Hai this is hari Hai this is hari



=================================================================================
Total Files: 2
All Files values are: /home/prabhucloudxlab/prabhu/input2.txt /home/prabhucloudxlab/prabhu2/input2.txt
difference is :
 Hai this is hari Hai this is hari Hai this is hari Hai this is hari



=================================================================================
difference files are:
 Hai this is prabhu Hai this is manyam Hai this is prabhu Hai this is taraka



=================================================================================
 the files name are: /home/prabhucloudxlab/prabhu/input2.txt and /home/adimulamvenkat19851609/prabhu2/input2.txt
Hai this is hari
Hai this is hari
Hai this is hari
Hai this is hari
 the files name are: /home/prabhucloudxlab/prabhu/input2.txt and /home/prabhucloudxlab/prabhu2/input.txt
 the files name are: /home/prabhucloudxlab/prabhu/input.txt and /home/prabhucloudxlab/prabhu2/input2.txt
 the files name are: /home/prabhucloudxlab/prabhu/input.txt and /home/prabhucloudxlab/prabhu2/input.txt
Hai this is prabhu
Hai this is manyam
Hai this is prabhu
Hai this is taraka