Text File difference.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Text File difference.
# 1  
Old 08-07-2010
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

Code:
029429288,1,,,02087400376,N,02087400376,N,0,02087400376,N,0,0,8010,08000151736,U,N,,08000151736,U,20100726111237,20100726111237,0,20100726111651,00004140,16,16,10,N;
029429289,1,,,02088736705,N,02088736705,N,0,02088736705,N,0,0,6160,003531437509,U,N,,003531437509,U,20100726111644,20100726111644,0,20100726111651,00000070,16,16,10,N;
029429290,1,,,02083995696,N,02083995696,N,0,02083995696,N,0,0,1363,07803049166,U,N,,07803049166,U,20100726111700,20100726111700,0,20100726111704,00000040,16,16,10,N;
029429291,1,,,01228631982,N,01228631982,N,0,01228631982,N,0,0,1363,07866387607,U,N,,07866387607,U,20100726121123,20100726121123,0,20100726122312,00011490,16,16,10,N;
029429292,1,,,01620844940,N,01620844940,N,0,01620844940,N,0,0,1877,01312402295,U,N,,01312402295,U,20100726121700,20100726121700,0,20100726122251,00005510,16,16,10,N;
029429293,1,,,01387262543,N,01387262543,N,0,01387262543,N,0,0,8091,01877242558,U,N,,01877242558,U,20100726122241,20100726122241,0,20100726122257,00000160,16,16,10,N;
029429294,1,,,01463783624,N,01463783624,N,0,01463783624,N,0,0,1363,01463811679,U,N,,01463811679,U,20100726122255,20100726122255,0,20100726122334,00000390,16,16,10,N;
029429295,1,,,01315537520,N,01315537520,N,0,01315537520,N,0,0,1363,08449999999,U,N,,08449999999,U,20100726121407,20100726121407,0,20100726122315,00009080,16,16,10,N;
COUNT=1000;

file1.txt[/SIZE]
Code:
029429288,1,,,02087400376,N,02087400376,N,0,02087400376,N,0,0,8010,08000151736,U,N,,08000151736,U,20100726111237,20100726111237,0,20100726111651,00004140,16,16,10,N;
029429289,1,,,02088736705,N,02088736705,N,0,02088736705,N,0,0,6160,003531437509,U,N,,003531437509,U,20100726111644,20100726111644,0,20100726111651,00000070,16,16,10,N;
029429290,1,,,02083995696,N,02083995696,N,0,02083995696,N,0,0,1363,07803049166,U,N,,07803049166,U,20100726111700,20100726111700,0,20100726111704,00000040,16,16,10,N;
029429291,1,,,01228631982,N,01228631982,N,0,01228631982,N,0,0,1363,07866387607,U,N,,07866387607,U,20100726121123,20100726121123,0,20100726122312,00011490,16,16,10,N;
029429292,1,,,01620844940,N,01620844940,N,0,01620844940,N,0,0,1877,01312402295,U,N,,01312402295,U,20100726121700,20100726121700,0,20100726122251,00005510,16,16,10,N;
029429294,1,,,01463783624,N,01463783624,N,0,01463783624,N,0,0,1363,01463811679,U,N,,01463811679,U,20100726122255,20100726122255,0,20100726122334,00000390,16,16,10,N;
029429295,1,,,01315536666,Y,01315537520,N,0,01315537520,N,0,0,1363,08449999999,U,N,,08449999999,U,20100726121407,20100726121407,0,20100726122315,00009080,16,16,10,N;
COUNT=999



I want to to write an shell script to compare above two files in a way so that three files can be generated with following data -

1) First file should have the records which are missing in file1.txt but available in
file1.txt.arch (Red colored record).

2) Second file should have records which have been modified (Green colored).

3) Third file should have the common records.

Please help me to provide the solution on this.

Thanks very much in advance.

Ravi

Last edited by Scott; 08-07-2010 at 02:31 PM.. Reason: Code tags, please. Removed formatting.
# 2  
Old 08-07-2010
Bug

use "diff" to compare files, then those values I guess can be search & replaced to highlight, using PERL, SED or whatever?

cheers!
# 3  
Old 08-08-2010
Hi,

As I am very new to shell scripting.Could you please help me to rite the script?

Thanks a lot.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies

2. Shell Programming and Scripting

Difference between /text/ and "text" in awk

Why does this search give different result in awk I do see a mix of this in the example around the net. What to use and why? data 1 = red 2 = green 3 = blue 4 = black awk '$3 == /blue/' data "no result" awk '$3 == "blue"' data 3 = blue awk '$3 ~ /blue/' data 3 = blue (9 Replies)
Discussion started by: Jotne
9 Replies

3. UNIX for Dummies Questions & Answers

Extracting lines from a text file based on another text file with line numbers

Hi, I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 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. UNIX for Dummies Questions & Answers

Converting a text file with irregular spacing into a space delimited text file?

I have a text file with irregular spacing between values which makes it really difficult to manipulate. Is there an easy way to convert it into a space delimited text file so that all the spaces, double spaces, triple spaces, tabs between numbers are converted into spaces. The file looks like this:... (5 Replies)
Discussion started by: evelibertine
5 Replies

7. Shell Programming and Scripting

search text file in file if this file contains necessary text (awk,grep)

Hello friends! Help me pls to write correct awk and grep statements for my task: I have got files with name filename.txt It has such structure: Start of file FROM: address@domen.com (12...890) abc DATE: 11/23/2009 on Std SUBJECT: any subject End of file So, I must check, if this file... (4 Replies)
Discussion started by: candyme
4 Replies

8. Shell Programming and Scripting

Difference between 2 zipped text files.

Hi, I have below two zipped files - file1.gz 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;... (8 Replies)
Discussion started by: ravigupta2u
8 Replies

9. Shell Programming and Scripting

Create multiple text file from a single text file on AIX

Hi I need to create multiple text files from onc text file on AIX. The data of text files is as below: ********************************************** ********************************************** DBVERIFY: Release 10.2.0.4.0 - Production on Tue Nov 10 13:45:42 2009 Copyright (c) 1982,... (11 Replies)
Discussion started by: lodhi1978
11 Replies

10. Shell Programming and Scripting

how can I bcp out a table into a text file including the header row in the text file

Hi All, I need to BCP out a table into a text file along with the table headers. Normal BCP out command only bulk copies the data, and not the headers. I am using the following command: bcp database1..table1 out file1.dat -c -t\| -b1000 -A8192 -Uuser -Ppassword -efile.dat.err Regards,... (0 Replies)
Discussion started by: shilpa_acc
0 Replies
Login or Register to Ask a Question