compare two text files in a good format


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers compare two text files in a good format
# 1  
Old 03-04-2009
compare two text files in a good format

I am writting a script where I have to Campare two text files.
I have 3 text files named by s_list, s_list_new and dmg_file. where I have to compare s_list and s_list_new and whatever the unique values are in s_list I have to add that in the dmg_file. And the values they are only in s_list_new and not in s_list I have to delete that from dmg_file
I have tried so many things, but diff, comm is not helping me because if i do comm it compares line by line and the value may not match line by line and with diff its not giving me exact output and I am thinking may be im not aware of different diff output formats.
for example if i do diff temp temp1 i get like this output and I dont want it. i just want thos unique values nothing else
diff temp temp1
1,5d0
< a
< 1
< 2
< 3
< 4
11c6,9
<
---
> 10
> 11
> 12
> 13

Any Help Plz
I will appreciate the help
# 2  
Old 03-05-2009
Experiment with grep and fgrep (grep -f). Check out the man page for those options. Mix in a little "sort | uniq -u" and you should get something pretty workable.
# 3  
Old 03-18-2009
Try with uniq command

cat temp temp1 | uniq
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare actual files with format

Hi, I have database table let say t_filenames which stores filenames and date_format in two columns. e.g. ABCD_TV_YYYYMMDD.txt YYYYMMDD ABCD_MOUSE_YYYYMMDDHHMISS.txt YYYYMMDDHHMISS Actual files are available in a directory (say /tmp), actual files are with... (2 Replies)
Discussion started by: pointers1234
2 Replies

2. Shell Programming and Scripting

Need script for transferring bulk files from one format to text format

"Help Me" Need script for transferring bulk files from one format to text format in a unix server. Please suggest (2 Replies)
Discussion started by: Kranthi Kumar
2 Replies

3. Shell Programming and Scripting

Compare two fields in text files?

Hi, I have two text files, compare column one in both the files and if it matches then the output should contain the id in column one, the number and the description. Both the files are sorted. Is there a one liner to get this done, kindly help. Thank you File 1: NC_000964 92.33 ... (2 Replies)
Discussion started by: pulikoti
2 Replies

4. Shell Programming and Scripting

Script to compare two text files

i am working on a shell script and need help in the comparing part of it. for e.g. there two text files like this: file1.txt name1 name2 name3 file1 has to be comared with file2 defaultfile.txt name1 name2 name3 name4 and during comparision with defaultfile.txt if... (2 Replies)
Discussion started by: draghun9
2 Replies

5. UNIX for Dummies Questions & Answers

Compare two text files

Hello guys, I have file1 and file2, two text files containing various lines. I'm trying to find a way to compare file1 and file2: If the first 7 characters of a line in file2 match the first 7 characters of a line in file1, then do not do anything. Print out the lines of file1 (in file3,... (3 Replies)
Discussion started by: bobylapointe
3 Replies

6. Shell Programming and Scripting

To compare the content of two text files

I have two files, sec.txt(1st File) 3172 disp.txt(2nd file) the file name is *********** 45676 Now i want to compare the value in sec.txt file with disp.txt file Excatly i want to compare the value 3172 in first file and 45676 in second file. i want to compare the first line of... (11 Replies)
Discussion started by: rammm
11 Replies

7. Shell Programming and Scripting

Format & Compare two huge CSV files

I have two csv files having 90K records each & each row has around 50 columns.Lets say the file names are FILE1 and FILE2. I have to compare both the files and generate a new file that has rows from FILE2 if it differs. FILE1 ----- 2001,"John",25,19901130,21211.41,Unix Forum... (3 Replies)
Discussion started by: Sheel
3 Replies

8. Shell Programming and Scripting

How to compare two text files

Hi Team, Could you please help me on below one .. etrademail1.txt etDefaultLogin=pdayanan mail=poojaaragam.dayanand@exchange.etr.comx employeeNumber=31567 etDefaultLogin=sudrupa mail=sudrupa.ayanand@exchange.etr.comx employeeNumber=318967 etDefaultLogin=gurathi (1 Reply)
Discussion started by: nivas_k2006
1 Replies

9. Shell Programming and Scripting

Compare 2 files and output only the different text.

I know the diff does this but it does output more info than just the different text (e.g. $ diff file1 file2 29a30 > /home/alex/Pictures/hello.jpg 1694a1696 > /home/alex/Pictures/hi.jpg ) How can I make it output only /home/alex/Pictures/hello.jpg /home/alex/Pictures/hi.jpg ? thank... (2 Replies)
Discussion started by: hakermania
2 Replies

10. UNIX for Dummies Questions & Answers

compare text files

This may be the 3rd time I'm posting this question. I'm so new here that I'm not even sure how to post! I'm trying to compare two files but can't do a line by line comparison so comm and diff are out. I've been told that I would need to use the awk programing language. I've looked up what I... (14 Replies)
Discussion started by: jimmyflip
14 Replies
Login or Register to Ask a Question