bug-coreutils
[Top][All Lists]
Advanced

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

Re: dirname - bug or feature?


From: Brian Dessent
Subject: Re: dirname - bug or feature?
Date: Fri, 23 Feb 2007 11:54:35 -0800

Fill Manuel wrote:

There's no need to reinvent this wheel.

> address@hidden:~> dirname ../testfile
> ..
> address@hidden:~> dirname-ng.pl ../testfile
> /home
> address@hidden:~>

$ dirname `readlink -m ../testfile`
/home

> address@hidden:~> dirname ../../../././testfile
> ../../.././.
> address@hidden:~> dirname-ng.pl ../../../././testfile
> /
> address@hidden:~>

$ dirname `readlink -m ../../../././testfile`
/

> address@hidden:~> dirname ../testfile /tmp/testfile2
> dirname: too many arguments
> Try `dirname --help' for more information.
> address@hidden:~> dirname-ng.pl ../testfile /tmp/testfile2
> /home
> /tmp
> address@hidden:~>

$ for F in ../testfile /tmp/testfile2; do dirname `readlink -m $F`; done
/home
/tmp

We already did this thread just a few weeks ago. 
<http://lists.gnu.org/archive/html/bug-coreutils/2007-02/msg00019.html>

> address@hidden:~> find /tmp/test/* | dirname | sort | uniq
> dirname: too few arguments
> Try `dirname --help' for more information.
> address@hidden:~> find /tmp/test/* | dirname-ng.pl - | sort | uniq
> /tmp/test
> /tmp/test/a
> /tmp/test/b
> /tmp/test/c
> /tmp/test/d

Now why in the world would you go to all that trouble?  You're listing
every single file and directory in the tree, only to then go and strip
the filename component entirely, resulting in massive duplication that
you then have to remove.  What's wrong with just telling find to list
directories: find /tmp/test -type d

Brian




reply via email to

[Prev in Thread] Current Thread [Next in Thread]