File Difference Problem

Hey all,

I have a scenario where i have two files

File-3rdjuly --- This has 3 records -(3 rows)

~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/faces/public/MUA/pages/loginPage.xhtml HTTP/1.1~||~200~||~48583~||~-~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~-~||~0~||~258828~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/includes/common/css/print.css HTTP/1.1~||~200~||~-~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~553~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/includes/common/css/main.css HTTP/1.1~||~200~||~180945~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~782~||~

File 4th July --- This has 5 records -(5 rows)

~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/faces/public/MUA/pages/loginPage.xhtml HTTP/1.1~||~200~||~48583~||~-~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~-~||~0~||~258828~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/includes/common/css/print.css HTTP/1.1~||~200~||~-~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~553~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/includes/common/css/main.css HTTP/1.1~||~200~||~180945~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~782~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:04 +0100]~||~GET /NestWeb/includes/MUA/css/IE.css HTTP/1.1~||~200~||~44~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~603~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:04 +0100]~||~GET /NestWeb/includes/common/js/jquery-1.4.min.js HTTP/1.1~||~200~||~69838~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~525~||~

-----------------------------

Well, 4th july file has 3rdjuly records and some new records.. Wel these are the flat files i am using to load in my warehouse now.

I want a program which will compare both 4thJuly and 3rdJuly files and extract me only new records from 4thjuly (which are not there in 3rd july) in a new file say 'NEWFILE'.

Please help me out with the same... pleasee

try with below code

rm -f newfile.txt
while read line
do
  line1=`grep -ie "${line}" 3rdjuly.txt`
  if [ $? -ne 0 ] ; then
    echo "$line" >> newfile.txt
  fi
done < 4thjuly.txt

you can also try with below
In this the difference between 3rdjuly.txt and 4thjuly.txt will be put into newfile.txt
since in this case 4thjuly.txt will have 3rdjuly.txt records as well as few
new records the new records will be put into newfile.txt

diff 3rdjuly.txt 4thjuly.txt > newfile.txt

Cheers
Harish

hi harish..

After executing the code block you gave me, i got first 4 rows from 4thjuly file.. This wasnt something i was expecting.

Dear sir, i need the records from 4thjuly file, which arn't part of 3rdjuly file.

Output of the code harish you gave was

 
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/faces/public/MUA/pages/loginPage.xhtml HTTP/1.1~||~200~||~48583~||~-~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~-~||~0~||~258828~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/includes/common/css/print.css HTTP/1.1~||~200~||~-~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~553~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/includes/common/css/main.css HTTP/1.1~||~200~||~180945~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~782~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:04 +0100]~||~GET /NestWeb/includes/MUA/css/IE.css HTTP/1.1~||~200~||~44~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~603~||~
 

try with below
In this the difference between 3rdjuly.txt and 4thjuly.txt will be put into newfile.txt
since in this case 4thjuly.txt will have 3rdjuly.txt records as well as few
new records the new records will be put into newfile.txt

diff 3rdjuly.txt 4thjuly.txt > newfile.txt

Cheers
Harish

Sir, i got the ouput as

 
3c3,5
< ~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/includes/common/css/main.css HTTP/1.1~||~200~||~180945~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~782~||~
---
> ~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/includes/common/css/main.css HTTP/1.1~||~200~||~180945~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~782~||~
> ~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:04 +0100]~||~GET /NestWeb/includes/MUA/css/IE.css HTTP/1.1~||~200~||~44~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~603~||~
> ~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:04 +0100]~||~GET /NestWeb/includes/common/js/jquery-1.4.min.js HTTP/1.1~||~200~||~69838~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~525~||~
 

I am expecting an output of

 
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:04 +0100]~||~GET /NestWeb/includes/MUA/css/IE.css HTTP/1.1~||~200~||~44~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~603~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:04 +0100]~||~GET /NestWeb/includes/common/js/jquery-1.4.min.js HTTP/1.1~||~200~||~69838~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~525~||~
 

If and only if the new records always appear at the end of the file, after all of the old records, you can use:

tail -n +$(($(wc -l < 3rdjuly)+1)) 4thjuly > NEWFILE

Regards,
Alister

If records are ordered the same way in the two file, you can do :

comm -3 3rdjuly.txt  4thjuly.txt

Jean-Pierre.

awk '!($0 in a){a[$0];if(FILENAME=="4")print}' 3 4 > new
1 Like

That will suppress duplicate records within 4. This could be a problem if one of the new lines in 4 is identical to an older line in 3 and 4.

1 Like

Amit,
Please check below.I have take the input 3rdjuly.txt and 4thjuly.txt
as per the your very first post
The results are same as you are expecting

Input:

cat 3rdjuly.txt

~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/faces/public/MUA/pages/loginPage.xhtml HTTP/1.1~||~200~||~48583~||~-~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~-~||~0~||~258828~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/includes/common/css/print.css HTTP/1.1~||~200~||~-~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~553~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/includes/common/css/main.css HTTP/1.1~||~200~||~180945~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~782~||~

cat 4thjuly.txt

~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/faces/public/MUA/pages/loginPage.xhtml HTTP/1.1~||~200~||~48583~||~-~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~-~||~0~||~258828~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/includes/common/css/print.css HTTP/1.1~||~200~||~-~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~553~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:03 +0100]~||~GET /NestWeb/includes/common/css/main.css HTTP/1.1~||~200~||~180945~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~782~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:04 +0100]~||~GET /NestWeb/includes/MUA/css/IE.css HTTP/1.1~||~200~||~44~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~603~||~
~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:04 +0100]~||~GET /NestWeb/includes/common/js/jquery-1.4.min.js HTTP/1.1~||~200~||~69838~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~525~||~
diff 3rdjuly.txt 4thjuly.txt > newfile.txt

Output:

cat newfile.txt
3a4,5
> ~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:04 +0100]~||~GET /NestWeb/includes/MUA/css/IE.css HTTP/1.1~||~200~||~44~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~603~||~
> ~||~172.16.44.102~||~-~||~Unauthenticated~||~[17/Jun/2011:09:02:04 +0100]~||~GET /NestWeb/includes/common/js/jquery-1.4.min.js HTTP/1.1~||~200~||~69838~||~https://tcsppdsw/schemeweb/NestWeb/faces/public/MUA/pages/loginPage.xhtml~||~Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)~||~org.apache.myfaces.shared_impl.context.flash.FlashImpl.POSTBACKMAP.KEY=-mmdxm8rb8; JSESSIONID=Qw5nN7JSLBgnW2LbGHJd72nMPBT1TNzP8bH13WJwpQvS4QggNm64!-63489622~||~0~||~525~||~

If you are expecting anything else let me know

Cheers
Harish

1 Like

Amit,
You can also try with below code
But this will search the 3rdjuly.txt for each line of the 4thjuly.txt

For eg :
Even if the 4thjuly.txt line 2 and 3rdjuly.txt line 2 are not same but that line is present in 3rdjuly.txt then it won't be displayed in the output

rm -f  newfile.txt
while read line
do
  line1=`fgrep -ie "${line}" 3rdjuly.txt `
  if [ $? -ne 0 ] ; then
    echo "$line" >> newfile.txt
  fi
done <4thjuly.txt

In case you want to get the difference on each line of both the files you can refer to my above post i.e using diff command

Cheers
Harish

1 Like

Thanks Alister and Harish :slight_smile:

Its working fine :slight_smile: cool..