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
Cutting specific lines from a file pathanjalireddy Shell Programming and Scripting 15 06-04-2009 02:32 AM
Urgent: selecting unique specific content of a file using shell script jisha Shell Programming and Scripting 2 01-08-2008 08:45 AM
replacing specific lines in a file hcclnoodles Shell Programming and Scripting 6 09-30-2006 12:35 PM
transfer of specific file content to another file mem101 Shell Programming and Scripting 1 10-18-2005 03:01 PM
How do you specific lines in a file? hedgehog001 UNIX for Dummies Questions & Answers 2 08-23-2005 01:04 AM

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 04-19-2008
chennaitomcruis chennaitomcruis is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 3
Retreive content between specific lines ina file

Hi
I have a text file which has two sets of lines repeating for "n" number of times.Some data is printed between the two lines.I want to retrieve all the data thats there in between those two set of lines.I have the string value of those two set of lines.
To be much more clearer

line1line1line1line1line1line1line1line1
datadatadatadatadatadatadatadat
datadatadatadatadatadatadatadata
line2line2line2line2line2line2line2line2
*
*
*
line1line1line1line1line1line1line1line1
data1data1data1data1data1data1
data1data1data1data1data1data1
line2line2line2line2line2line2line2line2
.
.
.
.this repeats for n number of times.

Pls help

Cheers
Vijay
  #2 (permalink)  
Old 04-19-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,322
Try this:

Code:
awk -v var1="begin_string" -v var2="end_string" '
$0==var1{f=0}
$0==var2{f++;next}f' file
Regards
  #3 (permalink)  
Old 04-19-2008
chennaitomcruis chennaitomcruis is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 3
Thanks a lot franklin.
But I get a syntax error at the semi colon part

Sorry ima perfect newbie to unix scripting
  #4 (permalink)  
Old 04-19-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,322
Use nawk or /usr/xpg4/bin/awk on Solaris

Regards
  #5 (permalink)  
Old 04-19-2008
chennaitomcruis chennaitomcruis is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 3
Hi
I managed to run it using another command awk '/string1/,/string2/'.

I have one more query...

I have a file which has values like the following..with a delimiter between sets of lines

Line1 value1
Line2 value1
Line 3 value1
------------
line 1 value2
line 2 value2
line 3 value2

will it be possibel for me to make a table sort of thing such that
underneath line 1..i have all values [value 1,value2] and underneath line 2 i have all the values
line1 line2
value1 value1
value2 value2

thanks for your time

Cheers
Vijay
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 11:20 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