euglug.org

[Eug-lug] calling all bash experts…

작성자

카테고리:



Rob HudsonThu Dec 8 15:34:09 PST 2005

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