Removing substring from a string | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Removing substring from a string

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-28-2005
dmilks dmilks is offline
Registered User
 
Join Date: May 2005
Last Activity: 16 August 2005, 5:15 PM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Removing substring from a string

Hi. I want to remove a substring from a string. If I use the "tr" command, it doesn't seem to to what I want it to:

echo './somestring.dat' | tr -d './'
results in
somestringdat

I want it to remove only occurances of the string './', rather than the individual character. The result should be: somestring.dat

How do I do this?

Thanks,
- Dylan
Sponsored Links
    #2  
Old 07-28-2005
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 17 September 2014, 9:48 AM EDT
Location: Foxborough, MA
Posts: 7,644
Thanks: 150
Thanked 577 Times in 542 Posts
echo './somestring.dat' | sed 's#\./##g'
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Substring from a String Noremak17 Shell Programming and Scripting 4 02-09-2011 03:26 PM
Help with string and substring also I/O ikeQ Shell Programming and Scripting 1 04-09-2010 01:08 PM
get substring from string suman.g Shell Programming and Scripting 5 07-09-2009 01:22 AM
How to get the substring from the string Anshu UNIX for Dummies Questions & Answers 3 06-15-2006 07:52 AM
getting a substring from a string maradona Shell Programming and Scripting 3 03-09-2005 11:05 AM



All times are GMT -4. The time now is 11:31 AM.