The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Is there a way to limit DIFF output bobk544 Shell Programming and Scripting 2 06-08-2007 04:54 PM
parsing output from ls command ajaya Shell Programming and Scripting 3 05-10-2006 11:22 AM
diff output paulp UNIX for Dummies Questions & Answers 3 04-14-2005 03:27 AM
reformat the output from "diff" command CamTu Shell Programming and Scripting 5 03-01-2005 10:54 AM
diff 2 files; output diff's to 3rd file blt123 Shell Programming and Scripting 2 05-28-2002 12:29 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-29-2007
kam kam is offline
Registered User
  
 

Join Date: May 2007
Posts: 4
parsing output from a diff command...

hi,

i have a script which pipes the output of a diff -rq command into a separate file/ it would read something like this:


Files mod1/lala/xml/test1.txt and mod2/lala/xml/test1.txt differ
Only in mod2/lala/xml: test2.txt

What i need to do is to parse this file so i end up with just a list of directories in which the differences occur:

i.e.

mod2/lala/xml/

any ideas?
  #2 (permalink)  
Old 05-29-2007
aigles's Avatar
aigles aigles is online now Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,432
You can try something like that :

Code:
awk '
   /^Files/ { sub(/\/[^\/]*$/, "", $(NF-1)); print $(NF-1) }
   /^Only/  { sub(/\/[^\/]*$/, "", $3     ); print $3      }
    ' diff_file | sort -u

Jean-Pierre.
  #3 (permalink)  
Old 05-29-2007
kam kam is offline
Registered User
  
 

Join Date: May 2007
Posts: 4
thanks jean-pierre, that works great!
  #4 (permalink)  
Old 05-29-2007
kam kam is offline
Registered User
  
 

Join Date: May 2007
Posts: 4
oops, spoke to soon.

the problem i'm having is that when files are only in one directory, i'm losing part of the path on output.

i.e. if test1.txt is in new, but not in old, i'm getting

mod2/lala

instead of:

mod2/lala/xml
  #5 (permalink)  
Old 05-29-2007
aigles's Avatar
aigles aigles is online now Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,432

Code:
awk '
   /^Files/ { sub(/\/[^\/]*$/, "", $(NF-1)); print $(NF-1) }
   /^Only/  { sub(/:$/,        "", $3     ); print $3      }
    ' diff_file | sort -u

Jean-Pierre.
  #6 (permalink)  
Old 05-30-2007
kam kam is offline
Registered User
  
 

Join Date: May 2007
Posts: 4
you're a life saver...thanks.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0