[lsb-discuss] readlink

Craig Scott audiofanatic at gmail.com
Wed Feb 23 16:19:07 PST 2011


Ah, then the Mac version uses very different options and offers none like the ones you listed according to the Mac man page for readlink. Interesting.....


On 24/02/2011, at 10:50 AM, Nelson H. F. Beebe wrote:

> Craig Scott <audiofanatic at gmail.com> writes today:
> 
>>> readlink on its own as a naked command actually won't do it for
>>> you. It needs to be called repeatedly until it returns an empty string
>>> before you can be sure all symbolic links have been followed.
> 
> Not so: use "readlink -f" or "readlink -e":
> 
> % file foo.l?
> foo.l1: empty
> foo.l2: symbolic link to `foo.l1'
> foo.l3: symbolic link to `foo.l2'
> foo.l4: symbolic link to `foo.l3'
> foo.l5: symbolic link to `foo.l4'
> 
> % readlink --version
> readlink (GNU coreutils) 8.9
> ...
> 
> % readlink foo.l5
> foo.l4
> 
> % readlink -f foo.l5
> /home/jones/foo.l1
> 
> % readlink -e foo.l5
> /home/jones/foo.l1
> 
> % readlink --help
> Usage: readlink [OPTION]... FILE
> Print value of a symbolic link or canonical file name
> 
>  -f, --canonicalize            canonicalize by following every symlink in
>                                every component of the given name recursively;
>                                all but the last component must exist
>  -e, --canonicalize-existing   canonicalize by following every symlink in
>                                every component of the given name recursively,
>                                all components must exist
>  -m, --canonicalize-missing    canonicalize by following every symlink in
>                                every component of the given name recursively,
>                                without requirements on components existence
>  -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
> 
> ...
> 
> -------------------------------------------------------------------------------
> - Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
> - University of Utah                    FAX: +1 801 581 4148                  -
> - Department of Mathematics, 110 LCB    Internet e-mail: beebe at math.utah.edu  -
> - 155 S 1400 E RM 233                       beebe at acm.org  beebe at computer.org -
> - Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe/ -
> -------------------------------------------------------------------------------

--
Craig Scott
Melbourne, Australia





More information about the lsb-discuss mailing list