Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

To find Difference

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-15-2013
Shenbaga.d Shenbaga.d is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 9 January 2015, 8:56 AM EST
Posts: 43
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 Unix and Linux 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 Unix and Linux 02-15-2013
Shenbaga.d Shenbaga.d is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 9 January 2015, 8:56 AM EST
Posts: 43
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 Unix and Linux 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 Unix and Linux 02-15-2013
Shenbaga.d Shenbaga.d is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 9 January 2015, 8:56 AM EST
Posts: 43
Thanks: 2
Thanked 0 Times in 0 Posts
the command should Find the difference of the row or lines
Sponsored Links
    #6  
Old Unix and Linux 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 Unix and Linux 02-16-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 18 April 2015, 6:23 AM EDT
Location: Aachen, Germany
Posts: 5,716
Thanks: 101
Thanked 1,504 Times in 1,413 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 11:10 AM.