UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 26th, 2009, 10:27 PM
NookLogan NookLogan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 2 NookLogan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 57 sec
Reputation Power: 0
Sed question

I am having a difficult time trying to figure out this case in a bash shell.

What I want to do is display all the lines that appear between parentheses in a text file.

Example TextFile:
My name is NookLogan
(Nook for short)
I would like to further my knowledge in UNIX
(I am having trouble
with this one little case and
I can't seem to figure it out)

The output I would like is:
(Nook for short)
(I am having trouble
with this one little case and
I can't seem to figure it out)

I've tried sed -n '/(/,/)/p' TextFile
This returns all the lines starting from (Nook for short) to the end.

Any help would be much appreciated
NookLogan

Reply With Quote
  #2  
Old October 27th, 2009, 11:49 PM
NookLogan NookLogan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 2 NookLogan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 57 sec
Reputation Power: 0
Please somebody help me!!!!!

Reply With Quote
  #3  
Old October 29th, 2009, 04:34 PM
iamroot iamroot is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2008
Posts: 82 iamroot User rank is Second Lieutenant (5000 - 10000 Reputation Level)iamroot User rank is Second Lieutenant (5000 - 10000 Reputation Level)iamroot User rank is Second Lieutenant (5000 - 10000 Reputation Level)iamroot User rank is Second Lieutenant (5000 - 10000 Reputation Level)iamroot User rank is Second Lieutenant (5000 - 10000 Reputation Level)iamroot User rank is Second Lieutenant (5000 - 10000 Reputation Level)iamroot User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 17 h 28 m 52 sec
Reputation Power: 70
I don't know that sed will be able to do this for you.. I would suggest perl or awk.

The closest I could iron out quickly w/ sed was this:
Code:
sed -n '/[()]/p'

But that does not traverse lines

Reply With Quote
  #4  
Old November 17th, 2009, 04:56 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,126 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 6 Days 18 h 48 m 36 sec
Reputation Power: 10
Quote:
Originally Posted by NookLogan
Please somebody help me!!!!!

sed -n '/(/,/)/p' filename
works for me
__________________
working on Solaris[5-9], preferred languages french and C.

Reply With Quote
  #5  
Old November 18th, 2009, 06:13 AM
deads deads is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 6 deads User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 3 sec
Reputation Power: 0
mmm...interesting...

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Sed question


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek