Computing.Net > Forums > Unix > Remove substring

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Remove substring

Reply to Message Icon

Name: khanati
Date: August 6, 2004 at 13:30:46 Pacific
OS: Linux
CPU/Ram: 256
Comment:

Hi All:

I have a string: TString str = "branch__leaf"

i want to copy the part before __ in str1 and copy the part after __ in str2. How can i do that. i am using TString.

Hope someone can help me.
Atif



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: August 9, 2004 at 08:41:02 Pacific
Reply:

Atif:

Hi, this is the easiest way:

str="branch__leaf"

OFS=$IFS
IFS="__"
set - $(echo $str)
str1=$1
str2=$2
echo $str1
echo $str2
IFS=OFS

Let me know if you need it explained.

Regards,

Nails


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Remove substring

awk remove form feed www.computing.net/answers/unix/awk-remove-form-feed/6222.html

Substring in Shell script www.computing.net/answers/unix/substring-in-shell-script/5313.html

Unix cmd for find and remove www.computing.net/answers/unix/unix-cmd-for-find-and-remove/2376.html