Leland Lucius wrote:
Quoting "McKown, John" <[EMAIL PROTECTED]>:


#!/bin/sh
newhome="/java160"
if [ ! -z "$JAVA_HOME" ]; then
PATH=$(echo "$PATH" | sed -e "s#$JAVA_HOME/bin##g;s/::/:/g")


Disregarding the adjacent colons (which don't matter anyway), reasonably
recent bashes can make the substitution:

:~ $ jh=x:y:z
:~ $ p=a:b:c
:~ $ p=${p//$jh}
:~ $ echo $p
a:b:c
:~ $ p=a:b:x:y:z:c
:~ $ p=${p//$jh}
:~ $ echo $p
a:b::c

And if you do want to eliminate the adjacent colons:

:~ $ p=${p//::/:}
:~ $ echo $p
a:b:c

Or if you really want to go wild:

:~ $ shopt -s extglob
:~ $ p=a:b:x:y:z:c
:~ $ echo ${p//?(:)$jh?(:)/:}
a:b:c
:~ $ p=a:b:c
:~ $ echo ${p//?(:)$jh?(:)/:}
a:b:c

(always trying to stay in-shell where possible.)
- Larry

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to