Re: rename v. script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 20, 2005 at 04:36:41PM -0400, Steven W. Orr wrote:
>  > foo=/a/b/c/dee.f
>  > basename $foo
> dee.f
>  > dirname $foo
> /a/b/c
> 
> But you're much better off not using any external programs when you have 
> the choice of using real builtin stuff.
> 
>  > echo ${foo##*/} ${foo%/*}
> dee.f /a/b/c

Well, that depends on what you're going for. The built-in solution will be
trivially faster, and will obviously have no external dependencies, but it's
*much* harder to understand at a glance ("basename" and "dirname" are almost
self-documenting). And, while basename and dirname are quite standard unix
and can be pretty much expected to work anywhere, the fancy expansion syntax
you use won't work under /bin/sh on Solaris, say.

-- 
Matthew Miller           mattdm@xxxxxxxxxx        <http://www.mattdm.org/>
Boston University Linux      ------>                <http://linux.bu.edu/>
Current office temperature: 79 degrees Fahrenheit.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux