[plug] string manipulation

Craig Dyke grail at westnet.com.au
Sat Apr 22 14:31:34 WST 2006


Howdy All

I am looking for two answers here:

1. Is there a better way than what I will show below?
2. How is what I am doing wrong as I have to split operation into two 
(will show what I mean)?

Currently:

I have written a script which uses find to set a variable --> var=`find 
/ -name $what_i_am_looking_for`

The what_i_am_looking_for variable is et earlier and is the name of a 
directory on my system.

My task is to set a new variable equal to the name of the parent 
directory to what I have found.

This is what works at the mo:   temp=${what_i_am_looking_for%/*}
                                              newVar=${temp##*/}

What I was trying to do was combine both:   
newVar=${${what_i_am_looking_for%/*}##*/}

The one above gets a Bad Substitution error.

Look forward to solutions.

Craig



More information about the plug mailing list