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 > 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
Add string to middle of a file Chiefos UNIX for Dummies Questions & Answers 15 12-31-2008 05:23 PM
Stripping the spaces in a string variable rag84dec Shell Programming and Scripting 3 03-27-2008 03:16 AM
stripping leftmost characters from string hcclnoodles Shell Programming and Scripting 5 11-02-2007 03:52 AM
Stripping a portion of string from behind!!! kumarsaravana_s UNIX for Dummies Questions & Answers 5 03-18-2007 02:21 PM
how to insert and delete characters in the middle of file ivancheung High Level Programming 7 10-11-2004 03:08 AM

 
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 05-12-2008
mcoblefias mcoblefias is offline
Registered User
  
 

Join Date: May 2008
Posts: 4
Exclamation stripping certain characters in at the middle of a string

I am trying to strip out certain characters from a string on both (left & right) sides. For example, line=see@hear|touch, i only want to echo the "hear" part. Well i have tried this approach:

line=see@hear|touch
templine=${line#*@} #removed "see@"
echo ${templine%%\|*} #removed "|touch"
hear

...apparently it worked but i want to do this in only one line. Can anyone suggest a way on how to do this?

Another question, what if i added some more characters like this:

line=see@hear|touch|smell

...now i wanted to separate each and every one of them dynamically* like this: (*the values for templine2, 3 & 4 may vary)

templine1=see
templine2=hear
templine3=touch
templine4=smell

...can anyone also suggest on this one?

Many thanks
 

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