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
string deletion, variable contents, fixed delimiters rebelbuttmunch Shell Programming and Scripting 2 03-24-2009 07:44 AM
script not working...select utility mobydick Shell Programming and Scripting 6 05-08-2008 07:33 AM
Encountered error! puspendu UNIX Benchmarks 0 09-07-2006 05:37 AM
Newline character not working for ksh sanikv Shell Programming and Scripting 11 06-23-2005 02:34 PM
554 Unallowed chars encountered abibbens UNIX for Advanced & Expert Users 1 01-29-2002 01:21 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 11-02-2009
Balaji PK Balaji PK is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 8
select contents between two delimiters (not working if newline in encountered)

Hi,

I am facing difficulties in selecting the contents between two delimiters when there is a new line occurs..

Eg:

Code:
>more sample.txt
abcd -- this is the first line %
efgh-- this is the 
second line and not 
able to print %
ijkl -- this is the 3rd line %


when i search for abcd and use the below command , i am able to print the desired contents between '--' and '%'.
But the same i am not able to print in the case of 'efgh' . Its only printing the 1st line of that word found.

pls tell me what correction to be included in this code.. or suggest me the code for this .

Code:
grep -w efgh sample.txt | awk -F"-" '{print $2}' | awk -F"||" '{print $1}'



Required output : this is the
second line and not
able to print


thanks in advance.
:-)

Last edited by Balaji PK; 11-02-2009 at 05:46 AM.. Reason: code tags, please...
 

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 06:58 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