[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AW: dirname - bug or feature?
From: |
Fill Manuel |
Subject: |
AW: dirname - bug or feature? |
Date: |
Mon, 26 Feb 2007 07:49:39 +0100 |
Hi again,
First of all, thanks for the answer. I didn't know that there was a
program like readlink. ;)
But: What's the deal with the -m option? The manpage of my readlink here
( SUSE Linux Enterprise Server 9 ) shows:
Usage: readlink [OPTION]... FILE
Display value of a symbolic link on standard output.
-f, --canonicalize canonicalize by following every symlink in
every
component of the given path recursively
-n, --no-newline do not output the trailing newline
-q, --quiet,
-s, --silent suppress most error messages
-v, --verbose report error messages
--help display this help and exit
--version output version information and exit
as you can see, no -m option here. I tried the -f option which works for
me. But I'm curious. Could you tell me what -m does?
The version of readlink here is:
readlink (coreutils) 5.2.1
Written by Dmitry V. Levin.
The last example with the "find" was just to show you that dirname can't
handle stdin and that it would be nice if it could ( i now know that
readlink in a loop also does that job, but I didn't know that ). That
wasn't a practical problem. Just example ;) ( needless to say .. a
stupid one ;P ).
Thanks again for your answer.
Manuel
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
- AW: dirname - bug or feature?,
Fill Manuel <=