Difference between 2 zipped text files.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Difference between 2 zipped text files.
# 1  
Old 06-29-2010
Difference between 2 zipped text files.

Hi,

I have below two zipped files -

file1.gz

Code:
023384148,1,,,02077301961,R,02077301961,N,0,02077301961,N,0,0,8010,02077300518,U,N,,02077300518,U,20100501011732,20100501011732,0,20100501011815,00000430,16,16,10,N;
023384149,1,,,02830263735,N,02830263735,N,0,02830263735,N,0,0,8010,02843725609,U,N,,02843725609,U,20100501004716,20100501004716,0,20100501004915,00001590,16,16,10,N;
023384150,1,,,01253736993,N,01253736993,N,0,01253736993,N,0,0,8010,01253640111,U,N,,01253640111,U,20100501000300,20100501000300,0,20100501000529,00002290,16,16,10,N;
COUNT=6

file2.gz

Code:
023384148,1,,,02077301961,N,02077301961,N,0,02077301961,N,0,0,8010,02077300518,U,N,,02077300518,U,20100501011732,20100501011732,0,20100501011815,00000430,16,16,10,N;
023384149,1,,,02830263735,N,02830263735,N,0,02830263735,N,0,0,8010,02843725609,U,N,,02843725609,U,20100501004716,20100501004716,0,20100501004915,00001590,16,16,10,N;
023384150,1,,,01253736993,N,01253736993,N,0,01253736993,N,0,0,8010,01253640111,U,N,,01253640111,U,20100501000300,20100501000300,0,20100501000529,00002290,16,16,10,N;
COUNT=00006;





1. I want to write a shell script which needs to compare both files line by line. Means, line 1 from file1 should be compared only line 1 from file2 only.

2. difference should go into another new file.

I am new to shell scripting so please assist me in this case.

Thanks
# 2  
Old 06-29-2010
Code:
gunzip file1.gz
gunzipfile2.gz
diff -l file1 file2 > anotherfile
gzip file1
gzip file2

This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 06-29-2010
Hi, try this (ksh93/bash):
Code:
diff <(gunzip -c file1.gz) <(gunzip -c file2.gz) > newfile

This User Gave Thanks to Scrutinizer For This Post:
# 4  
Old 06-29-2010
Thanks for the solution.

Thanks.
# 5  
Old 07-01-2010
file Compare

Hi,

Please help me to implement this correctly. I have below scenerio -

There follwing files in /home/ravi/input folder -

A1.OTL.ARCH.gz
A2.OTL.ARCH.gz
A3.OTL.ARCH.gz

There follwing files in /home/ravi/output folder -

A1.OTL.gz
A2.OTL.gz
A3.OTL.gz

Requirement -
Need to compare A1.OTL.ARCH.gz file with A1.OTL.gz
Need to compare A2.OTL.ARCH.gz file with A2.OTL.gz
Need to compare A3.OTL.ARCH.gz file with A3.OTL.gz

And need to send difference into new file.

File names at both locations are not same.
Could you please suggest eme to write shell script for same?


Thanks in advance.
# 6  
Old 07-03-2010
Please respond to my query

Please respond to my query
# 7  
Old 07-03-2010
Quote:
Originally Posted by ravigupta2u
Hi,

Please help me to implement this correctly. I have below scenerio -

There follwing files in /home/ravi/input folder -

A1.OTL.ARCH.gz
A2.OTL.ARCH.gz
A3.OTL.ARCH.gz

There follwing files in /home/ravi/output folder -

A1.OTL.gz
A2.OTL.gz
A3.OTL.gz

Requirement -
Need to compare A1.OTL.ARCH.gz file with A1.OTL.gz
Need to compare A2.OTL.ARCH.gz file with A2.OTL.gz
Need to compare A3.OTL.ARCH.gz file with A3.OTL.gz

And need to send difference into new file.

File names at both locations are not same.
Could you please suggest eme to write shell script for same?


Thanks in advance.
Hi.

I don't see how this question is any different from the first one, that has already been answered.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grabing the same timestamp from files that are ZIPPED

Hi, I am zipping more than 20 files that has same timestamp in all of them. I need to create the zip file with the same timestamp as in the files that are zipped. So I have files: Dummytest_20140601W110515_file1.txt Dummytest_20140601W110515_file2.txt ....... .......... (5 Replies)
Discussion started by: Saanvi1
5 Replies

2. Shell Programming and Scripting

Work with huge Zipped files

Hello dear members, I have one general and one specific question which I will be very grateful if you could help me with them. Let's start with my general question: 1. I am working on cluster computer shared with other people and I need to manipulate a big zipped text file of 13 GB. There is... (1 Reply)
Discussion started by: Homa
1 Replies

3. Shell Programming and Scripting

Renaming all files inside a zipped file

Hi, To all the Unix gurus this should be a simple task, but as a newbie I'm finding it hard to crack this. Any help is highly appreciated... Scenario: Step 1 : Move zip file from FTP folder to WORK folder Step 2: Unzip the file "Sample_YYYYMMDDHHMMSS.tar.gz" which contains many file... (10 Replies)
Discussion started by: asandy1234
10 Replies

4. Shell Programming and Scripting

Compare two text files and output difference

Hi experts, I am trying to compare two text files and output the difference to another file. I'm not strictly looking for differences in text but additional text at the end of one file that isn't in another, so basically comparing the file 2 against file 1 and printing any additional text to... (9 Replies)
Discussion started by: martin0852
9 Replies

5. Shell Programming and Scripting

Comparing text in 2 files and output difference in another file.

I have 2 files of almost same text apart from 2,3 ending lines. Now I want to get that difference in another file. e.g file1.txt is Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_livecd-lv_root 18G 2.4G 15G 14% / tmpfs 504M ... (12 Replies)
Discussion started by: kashif.live
12 Replies

6. Shell Programming and Scripting

Copy all zipped files from one folder to another

Hi everyone, when I try to copy *.gz files run cp within the correct source folder it works as follow: Source folder = C:/Documents and Settings/user/Recent papers/2771/ Destination folder = C:/Documents and Settings/user/My documents/1532/temp cp *.gz "C:/Documents and Settings/user/My... (2 Replies)
Discussion started by: cgkmal
2 Replies

7. Shell Programming and Scripting

Text File difference.

Hi, I have wrote the query on this issue but i hope i have not explained properly. So i am writing again. Sorry for trouble. file1.txt.arch ... (2 Replies)
Discussion started by: ravigupta2u
2 Replies

8. Linux

grep thru zipped files

Hi All, I need to check the logs and grep it. The problem is that the previous days are zipped with *.gz. How do grep on the *.gz? Thank you in advance. (1 Reply)
Discussion started by: itik
1 Replies

9. Shell Programming and Scripting

Greping from zipped files without unzipping

I have more than 500 gzipped files in a directory. I have one lookup file in the same directory with 200 key values. I need to get the name of the gzipped file which have any of these 200 key values. Here my criteria is do not unzip the files due to space constraint. Any suggestion? (3 Replies)
Discussion started by: kanu_kanu
3 Replies

10. UNIX for Dummies Questions & Answers

uploading Zipped files get 553 error

I am trying to upload .zip files to Unix server and get the error 553 qmerev2002.zip: Permission denied, what is my problem?? I am able to load other files and folders fine. (3 Replies)
Discussion started by: CoastGuard1970
3 Replies
Login or Register to Ask a Question