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.
> [EMAIL PROTECTED]:~> dirname ../testfile
> ..
> [EMAIL PROTECTED]:~> dirname-ng.pl ../testfile
> /home
> [EMAIL PROTECTED]:~>
$ dirname `readlink -m ../testfile`
/home
> [EMAIL PROTECTED]:~> dirname ../../../././testfile
> ../../.././.
> [EMAIL PROTECTED]:~> dirname-ng.pl ../../../././testfile
> /
> [EMAIL PROTECTED]:~>
$ dirname `readlink -m ../../../././testfile`
/
> [EMAIL PROTECTED]:~> dirname ../testfile /tmp/testfile2
> dirname: too many arguments
> Try `dirname --help' for more information.
> [EMAIL PROTECTED]:~> dirname-ng.pl ../testfile /tmp/testfile2
> /home
> /tmp
> [EMAIL PROTECTED]:~>
$ 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>
> [EMAIL PROTECTED]:~> find /tmp/test/* | dirname | sort | uniq
> dirname: too few arguments
> Try `dirname --help' for more information.
> [EMAIL PROTECTED]:~> 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
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils