![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to find files which has more than one occurance of pattern | Prahlad | Shell Programming and Scripting | 10 | 08-08-2008 09:16 AM |
| Count of matched pattern occurance | palash2k | UNIX for Dummies Questions & Answers | 3 | 04-24-2008 12:33 PM |
| Pattern not found : AWK , help | jkl_jkl | Shell Programming and Scripting | 7 | 03-12-2008 03:46 AM |
| getting the stanza names if the pattern found | vijaya2006 | Shell Programming and Scripting | 4 | 09-25-2007 06:03 AM |
| finding duplicate files by size and finding pattern matching and its count | jerome Sukumar | Shell Programming and Scripting | 2 | 12-01-2006 12:20 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
||||
|
Hi,
I have two files viz, rak1: $ cat rak1 Quote:
$ cat rak2 Quote:
Code:
sdiff rak1 rak2 Quote:
I have done this so far: Quote:
Also it would be appreciated if the output could be printed as [section X] <valInFile1/valInFile2> <valInFile1/valInFile2> and so on. Please Help me out |
| Forum Sponsor | ||
|
|
|
|||
|
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' 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;}'
Code:
>...|nawk NF; |
|||
| Google The UNIX and Linux Forums |