The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 07-23-2008
alex_5161 alex_5161 is offline
Registered User
  
 

Join Date: Jan 2007
Location: Detroit
Posts: 124
I do not see why you need the egrep. Use sed for that filtering - easy.
Now, using -n option you prevent sed from printing unnessesary line.
After that just print what you need: lines with section number and lines with changes:
Code:
> sdiff rak1 rak2 | grep -n "." | sed -n '/>$/d; /section/p; /[|<>]/p'
Ok, deleting still needed

The only not-nice, the sections with no changes will be in that printout

I could not get it by 'sed'
Easy with nawk:
Code:
>....|
nawk '{if ( ($0 !~ /section/) || (prev !~ /section/) ) print prev; prev=$0;}
        END{if ($0 !~ /section/) print $0;}'
Not clear why it has empty line in beginning and end; so, remove it by :
Code:
>...|nawk NF;