Mike CherbaThu Dec 8 15:41:34 PST 2005
Well, I'm not a bash expert, but personally I would use the following: path=`dirname $path` you might want to pull the man pages for "dirname" and "basename" which are on most systems I've ever used and should do what you want with less headache. My quick test of my memory follows: mcherba at estoc:~> export test=/home/mcherba/cvs_commands.txt mcherba at estoc:~> test=`dirname $test` mcherba at estoc:~> echo $test /home/mcherba On Thu, 2005-12-08 at 15:34, Rob Hudson wrote: > Given a variable with something like this in it: > /Volumes/Projects/Testing/Simple_Carbon_App.pkg > > I need to extract the base path to get: > /Volumes/Projects/Testing > > I found how to get the last part in an example, though I don't fully > understand what's going on. Assuming "path" has the first volume path, > calling this: > > path=${path##/*/} > > Will set path to: Simple_Carbon_App.pkg > > I'm looking for more or less the opposite of that. > > Any pointers to documentation would be good. Working code is nice too. :P > > Thanks, > Rob > _______________________________________________ > EUGLUG mailing list > euglug at euglug.org > http://www.euglug.org/mailman/listinfo/euglug -- Mike Cherba Cavium Networks 883 Brookside Dr Eugene, OR 97405 phone: (541) 684-3820 Cell: (541) 914-2188 mike.cherba at caviumnetworks.com www.caviumnetworks.com