Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Output if data in file a is different from file b

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-19-2017
kenshinhimura kenshinhimura is offline
Registered User
 
Join Date: Feb 2008
Last Activity: 21 July 2017, 9:02 AM EDT
Posts: 170
Thanks: 31
Thanked 2 Times in 2 Posts
Output if data in file a is different from file b


Code:
[:]$ cat a
cdaa73fbb819f8af88a90843ce559328966c55d2  aa
2d33d2a0dfda680ee6bdf7dd8a18fa842e368271  bb
da39a3ee5e6b4b0d3255bfef95601890afd80709  cc
[aguirar@soctxlab04:/tmp/test_repo]$

[:]$ cat b
c388353f63244b1891593c4072ee687e47d74010  /tmp/a/aa
2d33d2a0dfda680ee6bdf7dd8a18fa842e368271  /tmp/a/bb
[:]$

Will show output aa
Sponsored Links
    #2  
Old Unix and Linux 05-19-2017
vgersh99's Unix or Linux Image
vgersh99 vgersh99 is offline Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 20 October 2017, 12:28 PM EDT
Location: Foxborough, MA
Posts: 8,198
Thanks: 229
Thanked 785 Times in 732 Posts
With over 160+ posts... where exactly are stuck?
Sponsored Links
    #3  
Old Unix and Linux 05-19-2017
kenshinhimura kenshinhimura is offline
Registered User
 
Join Date: Feb 2008
Last Activity: 21 July 2017, 9:02 AM EDT
Posts: 170
Thanks: 31
Thanked 2 Times in 2 Posts
it will compare file a and file b.

---------- Post updated at 11:29 AM ---------- Previous update was at 10:46 AM ----------

I got ugly awk command..we can close this ticket though



Code:
awk '$1==$3 {print $2, "has the same checksum as", $4, "which is", $1,"and",$3}' c

---------- Post updated at 11:33 AM ---------- Previous update was at 11:29 AM ----------

I was hoping I can also print the lines that are not match. though i can do it via awk command again. but it will end up 2 liner awk command.

---------- Post updated at 11:33 AM ---------- Previous update was at 11:33 AM ----------

I was hoping I can also print the lines that are not match. though i can do it via awk command again. but it will end up 2 liner awk command.

---------- Post updated at 12:30 PM ---------- Previous update was at 11:33 AM ----------

My solution is wrong..it will only work if two directories are same files..and almost identical.
    #4  
Old Unix and Linux 05-19-2017
Don Cragun's Unix or Linux Image
Don Cragun Don Cragun is offline Forum Staff  
Administrator
 
Join Date: Jul 2012
Last Activity: 22 October 2017, 2:06 AM EDT
Location: San Jose, CA, USA
Posts: 10,554
Thanks: 554
Thanked 3,697 Times in 3,154 Posts
Why not use the command:

Code:
diff a b

to compare files a and b and show which lines are different.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk to reformat output if input file is empty, but not if file has data in it cmccabe Shell Programming and Scripting 3 03-20-2017 03:08 PM
Extra data in output file jiam912 Shell Programming and Scripting 4 03-01-2015 09:16 AM
Help with add existing file name as new data column in new output file perl_beginner Shell Programming and Scripting 3 01-13-2015 09:07 PM
Output all data of files into one file Manu1234567 Shell Programming and Scripting 11 10-08-2013 06:38 AM
split input data file and put into same output file rasmith Shell Programming and Scripting 4 04-21-2011 01:41 AM



All times are GMT -4. The time now is 11:39 AM.