From: "Michael C. Toren" <mct@netaxs.com>
Reply-To: plug@lists.nothinbut.net
To: plug@lists.nothinbut.net
Subject: Re: [Plug] String Conversion
Date: Sat, 11 Dec 1999 14:43:28 -0500 (EST)
> I'm trying to create a shell script and I've run into a stumbling block
in
> terms of converting one string into another. cut and tr don't seem to be
> able to do what I want. An example of what I want to do is if you had
the
> string "foobar" and you wanted to convert every instance of "oba" to
"josh",
> but you didn't want to convert the other o to anything. So the desired
> result would be "fojoshr"
If you're using a version of bash later than 2.0 (I believe), you can do
something along the lines of:
i=foobar
echo ${i/oba/josh}
Or, from other more traditional shells:
i=foobar
echo $i | sed -e s/oba/josh/
-mct
_______________________________________________
Plug maillist - Plug@lists.nothinbut.net
http://lists.nothinbut.net/mail/listinfo/plug