euglug.org

[Eug-lug] calling all bash experts…

작성자

카테고리:



Rob HudsonThu Dec 8 15:44:16 PST 2005

Looks like I can do:

path = `dirname $path` # for directory
path = `basename $path` # similar to path=${path##/*/}

Is this the best option?

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
>