David, et al --

...and then david said...
% 
% Ohad Ohad wrote:
% 
...
% > This means also if I have a linked list of links I want to get the real
% > file at the end.

Ohad, do you want to know where the link (chain) points or do you want to
get the data that's in the target file?


...
% 
% for(qw(file1 file2 file3)){
%         print "$_ -> ",readlink,"\n" if -l; }

This works for one link but not a link to a link to a file:

  bash-2.05a$ echo foo > a
  bash-2.05a$ ln -s a b
  bash-2.05a$ ln -s b c
  bash-2.05a$ ls -lF
  total 0
  -rw-r--r--  1 davidtg  wheel  4 Mar 21 10:04 a
  lrwxr-xr-x  1 davidtg  wheel  1 Mar 21 10:04 b@ -> a
  lrwxr-xr-x  1 davidtg  wheel  1 Mar 21 10:04 c@ -> b
  bash-2.05a$ perl -e 'for (qw(a b c)) { print "$_ -> ",readlink,"\n";} '
  a ->
  b -> a
  c -> b

Clearly one way to approach this is to check what you get out of
readlink and see if *it* is a link and continue recursing until you
get to the actual file.  Is there a way, though, to duplicate the -L
flag in ls?

  bash-2.05a$ ls -l c
  lrwxr-xr-x  1 davidtg  wheel  1 Mar 21 10:04 c -> b
  bash-2.05a$ ls -lL c
  -rw-r--r--  1 davidtg  wheel  4 Mar 21 10:04 c


TIA & HAND

:-D
-- 
David T-G                      * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to