Need to extract text repetitively between two patterns

Tags
script to extract text, shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 02-21-2013
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.
# 2  
Old 02-21-2013
Code:
sed -n '/\/home\//,/\[loading/p' file

This User Gave Thanks to balajesuri For This Post:
Vignesh58 (02-21-2013)
# 3  
Old 02-21-2013
Thanks a lot..It works!!

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

Thanks balajesuri...Smilie
Smilie
Login to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Extract lines between patterns squrcles Shell Programming and Scripting 10 01-18-2016 01:15 PM
Extract patterns with grep and align results Chugger Shell Programming and Scripting 3 11-19-2015 06:53 PM
Extract all the sentences that matched two patterns my_Perl Shell Programming and Scripting 1 06-23-2015 09:45 PM
Extract Lines Between 2 patterns if exist... DSommers Debian 3 09-29-2014 06:44 PM
Extract all the lines in between of 2 patterns and merge them prvnrk Shell Programming and Scripting 4 11-24-2013 05:10 AM
Extract multiple occurance of strings between 2 patterns sameermohite Shell Programming and Scripting 8 10-24-2013 07:41 AM
awk extract strings matching multiple patterns chrissycc Shell Programming and Scripting 8 10-13-2013 03:38 PM
Extract line between two patterns rajamohan Shell Programming and Scripting 4 12-03-2012 02:55 AM
Replacing text between two patterns azdps Shell Programming and Scripting 5 05-29-2012 08:23 AM
Search and extract matching patterns lucasvs UNIX for Dummies Questions & Answers 9 02-28-2012 05:04 AM
PERL: extract lines between two patterns mnithink Shell Programming and Scripting 11 01-23-2012 11:58 PM
Extract patterns and copy them in different files shoaibjameel123 Shell Programming and Scripting 5 08-26-2011 12:50 AM
Extract certain patterns from file. shoaibjameel123 Shell Programming and Scripting 2 07-08-2011 10:56 AM
Copying Text between two unique text patterns spindoctor UNIX for Dummies Questions & Answers 3 01-16-2009 03:42 AM
To extract the string between two patterns aajan Shell Programming and Scripting 6 09-17-2007 03:41 AM
All times are GMT -4. The time now is 12:30 AM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?