From: peter sands on
Yes you're right , taking the 'g' off does not work,
Using the tr method as posted , appears to do the job, though still
testing.

thanks
Pete.

From: Janis Papanagnou on
[Please quote context.]
[Please reply to the posting with the solution you are referring to.]

peter sands wrote:
> Yes you're right , taking the 'g' off does not work,
> Using the tr method as posted , appears to do the job, though still
> testing.

Assuming you are referring to:

list=$(echo $list | tr ' ' '\n' | grep -v '^test$' | tr '\n' ' ')

Mind that this command involves four(!) processes, which is a lot of
overhead compared to a plain shell solution.

On what platform are you working, what shells have you available?

If you have any modern shell (ksh93, bash, etc.) you can do

list="test1 test2 test test3 test4"
list=" $list "
printf "%s\n" "${list/ test / }"

to obtain

test1 test2 test3 test4

You may add the spaces to the data list (if it is under your control)
to simplify the code

list=" test1 test2 test test3 test4 "
printf "%s\n" "${list/ test / }"


Janis

>
> thanks
> Pete.
>