Compare & append


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Compare & append
# 1  
Old 05-23-2009
Compare & append

I need to write a Shell Script to compare two files & display the result. If the two files are different append them and store them in a new file. How do i proceed...can someone give me a coding ?
# 2  
Old 05-23-2009
Code:
diff file1 file2
if [[ $? -ne 0 ]]
cat file1 file2> newfile
fi


Last edited by radoulov; 05-23-2009 at 01:16 PM.. Reason: added code tags
# 3  
Old 05-24-2009
you can use cmp to compare the two files.
Code:
cmp file1 file2

# 4  
Old 05-25-2009
Thanks ! the replies were useful ! I could build upon it !
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need solution to compare two file and update and append the output

Hi All, I have two files File1 frame,007C1 server1_Parent frame,007C3 server2_Silver frame,007EE server3_Bronze frame,00855 server4_Parent frame,00856 server4_Parent frame,00858 server5_Parent frame,008FA server6_Silver frame,008FB server6_Silver frame,008FC server6_Silver... (2 Replies)
Discussion started by: ranjancom2000
2 Replies

2. Shell Programming and Scripting

UNIX compare, sort lines and append difference

To make it easier, i gave following example. It is not homework or classwork. Instead, i have a huge csv file dump from tsql with 15 columns and around 300 rows. I was able to extract content that needs to be really converted. Here is the extract: ES FP,B1ES FP,70000,I,SL22,SL22 (70000) ES... (8 Replies)
Discussion started by: nike27
8 Replies

3. Shell Programming and Scripting

UNIX compare, sort lines and append difference

To make it easier, i gave following example. It is not homework or classwork. Instead, i have a huge csv file dump from tsql with 15 columns and around 300 rows. I was able to extract content that needs to be really converted. Here is the extract: ES FP,B1ES FP,70000,I,SL22,SL22 (70000) ES... (0 Replies)
Discussion started by: nike27
0 Replies

4. Shell Programming and Scripting

UNIX compare, sort lines and append difference

Hi, I have a file that needs to be converted: content is: a, b, 4 a ,b, 5 x, y, 1 a, b, 1 x, y, 3 how can i get: a, b, 1|4|5 x,y 1|3 (1 Reply)
Discussion started by: nike27
1 Replies

5. Shell Programming and Scripting

Compare a common field in two files and append a column from File 1 in File2

Hi Friends, I am new to Shell Scripting and need your help in the below situation. - I have two files (File 1 and File 2) and the contents of the files are mentioned below. - "Application handle" is the common field in both the files. (NOTE :- PLEASE REFER TO THE ATTACHMENT "Compare files... (2 Replies)
Discussion started by: Santoshbn
2 Replies

6. Shell Programming and Scripting

Copy & Append text

Hi, I have a huge text file that contains contents like below. echo 2VPMUM1CMP01_2011-05-10_18_CPU_Stats_1.txt awk -F, '{sub ("%","",$8);sum+=100-$8;if (100-$8>max){max=100-$8}}END{printf "max=%.1f%\navg=%.1f%\n",max,sum/NR}' echo 2VPMUM1CMP01_2011-05-11_10_CPU_Stats_1.txt awk -F,... (2 Replies)
Discussion started by: SunilB2011
2 Replies

7. Programming

Compare two files of 4 columns and o/p unique,append zero's

I have to files File1 1 23 2 34 3 7 4 56 5 61 6 22 7 65 File2 2 21 4 32 7 22 Now i need to compare column1 of both the files and generate a third file which should contain all the values of 1st column of 1st file and in the second column i need to get the coressponding row... (2 Replies)
Discussion started by: kamuju
2 Replies

8. UNIX for Dummies Questions & Answers

How to compare 2 files & get specific value & replace it in other file.

Hiiii Friends I have 2 files with huge data. I want to compare this 2 files & if they hav same set of vales in specific rows & columns i need to get that value from one file & replace it in other. For example: I have few set data of both files here: a.dat: PDE-W 2009 12 16 5 29 11.11 ... (10 Replies)
Discussion started by: reva
10 Replies

9. Shell Programming and Scripting

Append && echo "success" to all commands

I am learning to build from SVN and other tools, with a lot of copying and pasting from forums. I like to append && echo "success" to all commands so that I can see at a glance if things went all right. Is there a way that I can have the bash shell append this to all commands? Thanks! (5 Replies)
Discussion started by: dotancohen
5 Replies

10. UNIX for Dummies Questions & Answers

Match & append the files

Hi All, I have a problem in appending the files File 1 0.0000001 0.500000039894 0.0000002 0.500000079788 0.0000003 0.500000119683 0.0000004 0.500000159577 0.0000005 0.500000199471 0.0000006 0.500000239365 0.0000007 0.500000279260 0.0000008 0.500000319154 0.0000009 0.500000359048... (2 Replies)
Discussion started by: shashi_kiran_v
2 Replies
Login or Register to Ask a Question