zsh-users
 help / color / mirror / code / Atom feed
* Dereferencing a symlink...or that alike...
@ 2013-08-18  2:40 meino.cramer
  2013-08-18  4:30 ` Phil Pennock
  2013-08-18  5:05 ` Bart Schaefer
  0 siblings, 2 replies; 4+ messages in thread
From: meino.cramer @ 2013-08-18  2:40 UTC (permalink / raw)
  To: zsh-users

Hi,

suppose I have the following symlink in my $HOME

    etcetera -> /etc

. Is there a way to get back "/etc" only (not the contents
of /etc/. nor "etcetera") when doing a 'ls' or such?

Thank you very much in advance for any help!
Best regards,
mcc




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Dereferencing a symlink...or that alike...
  2013-08-18  2:40 Dereferencing a symlink...or that alike meino.cramer
@ 2013-08-18  4:30 ` Phil Pennock
  2013-08-18  5:05 ` Bart Schaefer
  1 sibling, 0 replies; 4+ messages in thread
From: Phil Pennock @ 2013-08-18  4:30 UTC (permalink / raw)
  To: meino.cramer; +Cc: zsh-users

On 2013-08-18 at 04:40 +0200, meino.cramer@gmx.de wrote:
> suppose I have the following symlink in my $HOME
> 
>     etcetera -> /etc
> 
> . Is there a way to get back "/etc" only (not the contents
> of /etc/. nor "etcetera") when doing a 'ls' or such?

The not-specific-to-zsh bit:

  $ ls -Lld etcetera

The -L says to chase the symlink when given on the command-line.  You
then want -d to not list the contents of the directory, only the
directory itself.

The options require vary by command used.

For the zsh "zstat" module-provided builtin, "zstat -L" will give you a
"link" field.

  % zstat -L +link etcetera 
  /etc

-Phil


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Dereferencing a symlink...or that alike...
  2013-08-18  2:40 Dereferencing a symlink...or that alike meino.cramer
  2013-08-18  4:30 ` Phil Pennock
@ 2013-08-18  5:05 ` Bart Schaefer
  2013-08-19  4:13   ` Phil Pennock
  1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2013-08-18  5:05 UTC (permalink / raw)
  To: zsh-users

On Aug 18,  4:40am, meino.cramer@gmx.de wrote:
}
} suppose I have the following symlink in my $HOME
} 
}     etcetera -> /etc
} 
} . Is there a way to get back "/etc" only (not the contents
} of /etc/. nor "etcetera") when doing a 'ls' or such?

Depends on what is covered by "or such" ...

    % zmodload zsh/stat
    % zstat +link etcetera
    /etc

However, that prints nothing if the file is not a symbolic link.

I don't know of any external utility that will print *only* the target
of the symlink.  E.g.

    % /usr/bin/stat --format=%N etcetera
    'etcetera' -> '/etc'


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Dereferencing a symlink...or that alike...
  2013-08-18  5:05 ` Bart Schaefer
@ 2013-08-19  4:13   ` Phil Pennock
  0 siblings, 0 replies; 4+ messages in thread
From: Phil Pennock @ 2013-08-19  4:13 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

On 2013-08-17 at 22:05 -0700, Bart Schaefer wrote:
> I don't know of any external utility that will print *only* the target
> of the symlink.  E.g.

readlink(1) is part of GNU coreutils and is part of the base system on
FreeBSD, OpenBSD, etc.

% readlink etcetera
/etc

(On FreeBSD, at least, it's a hardlink to the stat(1) command, which
 switches behaviour if argv[0] shows it was invoked as readlink.)

-Phil


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-08-19  4:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-18  2:40 Dereferencing a symlink...or that alike meino.cramer
2013-08-18  4:30 ` Phil Pennock
2013-08-18  5:05 ` Bart Schaefer
2013-08-19  4:13   ` Phil Pennock

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).