Unix/Linux
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives FAQs Unix/Linux

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old June 30th, 2008, 02:30 PM
jaredsubman
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
bash script to display words in parentheses

I have this:
var="I said ( hello world ) and the world said hello back."
var=${var#*(}
echo ${var%)*}

which outputs:
hello world

as expected.

However, I am trying to simply turn that into a one-liner which I've
been completely unsuccessful with.
The reason is that it has no significant advantage currently over cut/
awk/sed solutions as the variable is being re-defined. Does anybody
know how I can turn the above into a one-liner?

The following command (and many other variants) do not work:

echo ${var#*(%)*}

Any help would be much appreciated. Thanks.

Reply With Quote
Reply

Viewing: Web Development Archives FAQs Unix/Linux > bash script to display words in parentheses


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 Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT