How to compare file leaving certain filelds?

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat How to compare file leaving certain filelds?
# 1  
Old 06-17-2013
How to compare file leaving certain filelds?

How to compare two files leaving certain fields, using diff command the
entire file is being compared.

Can any one please help.
# 2  
Old 06-17-2013
Show the input you have and the output you want.
# 3  
Old 06-17-2013
the file which i have to compare is like this
Code:
VERSION = 2
SWI_ID = Ericsson3GSGSN
FILE_SEQ_NBR = 695
TOTAL_RECS = 233
FIRST_DTTM = 2008-07-21 16:42:12
LAST_DTTM = 2008-07-21 17:15:58
ORIG_FILE_NAME = UN00695.chg
CONVERTED_REC_STATS = MOC:150;MTC:83
REJECTED_REC_STATS = REJ:0
DISCARDED_REC_STATS =
ADDED_RECS_STATS  = 0
ADD_DUP_CHK_KEY  =
GEN_FIELD_NAME_1  =
GEN_FIELD_NAME_2  =

i dont want the LAST_DTTM field to be compared with a similar type of files .
# 4  
Old 06-17-2013
That's half the input, and none of the output. Can you show the other half of the input, and the matching output please?
# 5  
Old 06-17-2013
the another input file is similar to the 1st input file which i have shown
only last_dttm is different . i have to compare these file using a shell script
and echo that both the files are similar.
# 6  
Old 06-17-2013
Try this
Code:
diff -y -b --suppress-common-lines file file1 | grep -v LAST_DTTM
DISCARDED_REC_STATS =                          |    DISCARDED_REC_STATS = 7

Works with diff (GNU diffutils) 3.2 on linux.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Leaving directory Error

Hi, i have a question, when I install any software it give error message like as follow : sudo make password for csm: make all-recursive make: Entering directory `/home/csm/Desktop/miRanda-3.3a' Making all in man make: Entering directory `/home/csm/Desktop/miRanda-3.3a/man' make:... (18 Replies)
Discussion started by: harpreetmanku04
18 Replies

2. Shell Programming and Scripting

Leaving last 30 lines

If we want to display lines from file leaving last 30 lines. i dont know the count of lines in file (14 Replies)
Discussion started by: mirwasim
14 Replies

3. UNIX for Advanced & Expert Users

In a huge file, Delete duplicate lines leaving unique lines

Hi All, I have a very huge file (4GB) which has duplicate lines. I want to delete duplicate lines leaving unique lines. Sort, uniq, awk '!x++' are not working as its running out of buffer space. I dont know if this works : I want to read each line of the File in a For Loop, and want to... (16 Replies)
Discussion started by: krishnix
16 Replies

4. Shell Programming and Scripting

Leaving for loop on condition

hi all, i have a problem...no dream :-) i want to scan a file i use the loop famous while read line do do < myfile but this scan must finish when find the another string . How can i do it? best regards for all. Francesco Please use descriptive subjects. "script." doesn't tell... (5 Replies)
Discussion started by: FrancescoIt
5 Replies

5. UNIX for Dummies Questions & Answers

Delete all rows but leaving first and last ones

Hello, Merry Christmas to all! I wish you the best for these holidays and the best for the next year 2011. I'd like your help please, I need to delete all the rows in the third column of my file, but without touching nor changing the first and last value position, this is an example of my... (2 Replies)
Discussion started by: Gery
2 Replies

6. Solaris

leaving ALOM mode

Some netra 240 machines went into ALOM mode, and when I issue the command; sc> console it got stuck, does it mean Solaris OS had crashed ? or what can I do to reboot,because reboot is not starting? And advice ? (3 Replies)
Discussion started by: xramm
3 Replies

7. UNIX for Dummies Questions & Answers

delete string in a text file leaving the first occurrence

Hi, How can i delete the second and subsequent occurrence of a particular string from a file ? eg) test.txt cattle bat battle mat matter cattle cattle my output file should be cattle bat battle mat matter (12 Replies)
Discussion started by: gopskrish
12 Replies

8. UNIX for Dummies Questions & Answers

Searching a file withoug leaving home directory!!

hello there ! I am in my current working directory, and i want search a file in "dev" directory which is under root(/), but i donot want leave my current working directory. is it possible to find file like that ? let us say i am in /home/bin/user/malik/abid directory and i want find a file... (2 Replies)
Discussion started by: abidmalik
2 Replies
Login or Register to Ask a Question