The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
select a record from one file matching from second file using awk synmag Shell Programming and Scripting 7 06-12-2008 02:37 AM
Building Full-Text Search Applications with Oracle Text iBot Oracle Updates (RSS) 0 04-06-2008 05:10 AM
Wall, Write, select users, pipe a text file, HELP Before I'm Bald! chimodel UNIX Desktop for Dummies Questions & Answers 1 03-13-2008 05:50 PM
how to delete line with matching text and line immediately after orahi001 UNIX for Dummies Questions & Answers 6 01-15-2008 12:34 AM
Tournament Pool and Bracket Tracker 0.5.1 (Default branch) iBot Software Releases - RSS News 0 12-31-2007 04:40 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
  #1 (permalink)  
Old 04-19-2007
cursive cursive is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 6
Select text within matching ( ) bracket

Hi,

I am looking for a simple command to select text within a open bracket "("
and a matching close bracket ")" and output the within-bracket-text to a file.
This function is similar to the common vi select a range of text with "(" to ")"
but not sure how to run the same function in command line.

Here's the input file :

statement statement statement
statement statement statement
statement statement statement

Today( "here"

MONDAY = map( "monday")
TUESDAY = map( "tuesday" )

WESNESDAY = map( "wednesday" )
THURSDAY = map( "thursday" )
FRIDAY = map( "friday" )

SATURDAY = map( "saturday" )
SUNDAY = map( "sunday" )

);

statement statement statement
statement statement statement
statement statement statement

Output file :
--------------

Today( "here"

MONDAY = layer( "monday" )
TUESDAY = layer( "tuesday" )

WESNESDAY = layer( "wednesday" )
THURSDAY = layer( "thursday" )
FRIDAY = layer( "friday" )

SATURDAY = pinText( "saturday" )
SUNDAY = pinText( "sunday" )

);


Thanks in advance,
cursive
  #2 (permalink)  
Old 04-19-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
sed -n "/^[^)]*([^)]*$/,/^[^(]*)[^(]*/p" file
  #3 (permalink)  
Old 04-20-2007
cursive cursive is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 6
Hi,

Abou the code : sed -n "/^[^)]*([^)]*$/,/^[^(]*)[^(]*/p" file
the system prompt error message, "Illegal variable name"

I am not sure whether I missing something here, could someone
show me the right path ?

Thanks in advance,
cursive
  #4 (permalink)  
Old 04-20-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Quote:
Originally Posted by cursive
Hi,

Abou the code : sed -n "/^[^)]*([^)]*$/,/^[^(]*)[^(]*/p" file
the system prompt error message, "Illegal variable name"

I am not sure whether I missing something here, could someone
show me the right path ?

Thanks in advance,
cursive
Try using single quotes
Code:
$ cat file
statement statement statement
statement statement statement
statement statement statement

Today( "here"

MONDAY = map( "monday")
TUESDAY = map( "tuesday" )

WESNESDAY = map( "wednesday" )
THURSDAY = map( "thursday" )
FRIDAY = map( "friday" )

SATURDAY = map( "saturday" )
SUNDAY = map( "sunday" )

);

statement statement statement
statement statement statement
statement statement statement
$ sed -n '/^[^)]*([^)]*$/,/^[^(]*)[^(]*/p' file
Today( "here"

MONDAY = map( "monday")
TUESDAY = map( "tuesday" )

WESNESDAY = map( "wednesday" )
THURSDAY = map( "thursday" )
FRIDAY = map( "friday" )

SATURDAY = map( "saturday" )
SUNDAY = map( "sunday" )

);
  #5 (permalink)  
Old 04-20-2007
cursive cursive is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 6
Hi Anbu23,

A small tweak in the command is finally working well.
I really apperciated for all your help.

Thanks,
cursive
Sponsored Links
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 10:55 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