Need to extract text repetitively between two patterns | Unix Linux Forums | Shell Programming and Scripting

  Unix/Linux Go Back    


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

Need to extract text repetitively between two patterns

Shell Programming and Scripting


Tags
script to extract text

Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-21-2013
Vignesh58 Vignesh58 is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 21 February 2013, 8:16 AM EST
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Need to extract text repetitively between two patterns

Hi All,

I want to extract the text between some pattern which occurs repeatedly in a file. For example my input is like,

Code:
   [javac] [checking .....
   [javac] [checking .....
   [javac] [checking .....
   [javac] [checking .....
   [javac] /home/.....
             ..........java:25: cannot find symbol
    [javac] 
    [javac]............
    [javac] /home/......
    [javac] [loading java/lang/Math.class(java/lang:Math.class)]
    [javac] /home/.......
    [javac] [checking.......
    [javac] [checking.......
    [javac] [checking.......

I want to display text between "[javac] /home" upto "[javac] [" including these lines.

My output should look like..

Code:
    [javac] /home/.....
             ..........java:25: cannot find symbol
    [javac] 
    [javac]............
    [javac] /home/......
    [javac] [loading ...
    [javac] /home/.......
    [javac] [checking.......

Please help me to do that in shell script.
Sponsored Links
    #2  
Old Unix and Linux 02-21-2013
balajesuri's Unix or Linux Image
balajesuri balajesuri is offline Forum Advisor  
#! /bin/bash
 
Join Date: Apr 2009
Last Activity: 30 March 2015, 2:33 AM EDT
Location: India
Posts: 1,872
Thanks: 27
Thanked 536 Times in 513 Posts

Code:
sed -n '/\/home\//,/\[loading/p' file

The Following User Says Thank You to balajesuri For This Useful Post:
Vignesh58 (02-21-2013)
Sponsored Links
    #3  
Old Unix and Linux 02-21-2013
Vignesh58 Vignesh58 is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 21 February 2013, 8:16 AM EST
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Thanks a lot..It works!!

---------- Post updated at 05:23 PM ---------- Previous update was at 05:20 PM ----------

Thanks balajesuri...Unix or Linux Image
Unix or Linux Image
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
Extract line between two patterns rajamohan Shell Programming and Scripting 4 12-03-2012 01:55 AM
PERL: extract lines between two patterns mnithink Shell Programming and Scripting 11 01-23-2012 10:58 PM
Extract patterns and copy them in different files shoaibjameel123 Shell Programming and Scripting 5 08-25-2011 11:50 PM
Extract certain patterns from file. shoaibjameel123 Shell Programming and Scripting 2 07-08-2011 09:56 AM
To extract the string between two patterns aajan Shell Programming and Scripting 6 09-17-2007 02:41 AM



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