To find Difference | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

To find Difference

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-15-2013
Shenbaga.d Shenbaga.d is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 12 August 2014, 9:19 AM EDT
Posts: 41
Thanks: 2
Thanked 0 Times in 0 Posts
To find Difference

Hi Friends,

I need to find the difference between two files ,

File_1 contained 4 columns, and File_2 contained 4 columns,

I need to find the difference using 1st column,

Or need to find the difference using 3st column,
Sponsored Links
    #2  
Old 02-15-2013
user8 user8 is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 24 April 2013, 10:34 AM EDT
Posts: 36
Thanks: 0
Thanked 19 Times in 14 Posts
For detecting differences in the first field (if this is what you mean with "column"), you could try:

Code:
paste File_1 File_2 | awk '$1 != $5'

Sponsored Links
    #3  
Old 02-15-2013
Shenbaga.d Shenbaga.d is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 12 August 2014, 9:19 AM EDT
Posts: 41
Thanks: 2
Thanked 0 Times in 0 Posts
I need the count difference of the files

Which present like
File 1

Code:
1 a
2 b
3 c
4 e


File 2:

Code:
1 e
2 f
3 g


I need the row count, here compare two file 2 has -1 count.

    #4  
Old 02-15-2013
user8 user8 is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 24 April 2013, 10:34 AM EDT
Posts: 36
Thanks: 0
Thanked 19 Times in 14 Posts
Hmm. I don't really understand what the issue is. Please wrap data and code in CODE tags.
Sponsored Links
    #5  
Old 02-15-2013
Shenbaga.d Shenbaga.d is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 12 August 2014, 9:19 AM EDT
Posts: 41
Thanks: 2
Thanked 0 Times in 0 Posts
the command should Find the difference of the row or lines
Sponsored Links
    #6  
Old 02-15-2013
user8 user8 is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 24 April 2013, 10:34 AM EDT
Posts: 36
Thanks: 0
Thanked 19 Times in 14 Posts
See the man page of the wc utility: "wc - print newline, word, and byte counts for each file"
Sponsored Links
    #7  
Old 02-16-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 21 October 2014, 9:27 AM EDT
Location: Aachen, Germany
Posts: 4,406
Thanks: 73
Thanked 1,076 Times in 1,015 Posts
Quote:
Originally Posted by Shenbaga.d View Post
. . .
File_1 contained 4 columns, and File_2 contained 4 columns,
I need to find the difference using 1st column,
Or need to find the difference using 3st column
Quote:
File 1
Code:
1 a
2 b
3 c
4 e
File 2:
Code:
1 e
2 f
3 g
Not sure I understand (or, better: sure I don't understand). You say in post #1, both files have 4 columns, but the files presented have two cols only.
Please be far more clear in specifying your requirements, telling us what comes from where and goes to where based on what conditions. And, be sure to tell rows from columns!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find time difference wnaguib UNIX for Dummies Questions & Answers 23 06-29-2012 05:35 PM
How to find time difference? wnaguib Shell Programming and Scripting 1 06-25-2012 10:56 AM
To find difference between two files on a whole anandek Shell Programming and Scripting 2 06-20-2012 09:14 AM
Find difference between 2 files kanthrajgowda UNIX for Advanced & Expert Users 2 04-07-2011 09:10 PM
Difference between locate and find camerja1 UNIX for Dummies Questions & Answers 1 06-25-2002 01:55 PM



All times are GMT -4. The time now is 02:21 PM.