Comparing one file’s 3rd column to other file’s column and print – Linux/Unix

This script is created for my brother as he wanted to print the only values which are different from each other in both files but only in 3rd Column.
In this, the first column contains a unique id.

 

#!/bin/bash
awk -F "," '{print $1}' yash > yashids
for n in `cat yashids`
do
ID=`grep $n net | awk -F "," '{print $3}'`
ID2=`grep $n yash | awk -F "," '{print $3}'`
if [ "$ID" != "$ID2" ]
then
grep $n net yash
fi
done

 

Tags:-
Gagandeep Gagan Gagandeep920d

Leave a Reply