Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: checking link files
- X-seq: zsh-users 11684
- From: "Matt Wozniski" <godlygeek@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: checking link files
- Date: Sat, 28 Jul 2007 21:51:17 -0400
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=V9MgjhpUqcsdyCohh/xxQOrL+XDy+BKw7Z8eUYMz3ZfN0A1XlrK05/D5rEbcpVv9lx5H0kiBvuMZWKGde3ItIUknL0rOUdW7hIK8ZY0ZRMhsKk2kJWCyf+1aC91mCf0J7i0mXJq/MqYEY+XUaGKR3YNBxYWCrqzGpFUsAXPUxrc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=TbN6Q4fsncH3hbKWi1Ri9j3qx7l2rBCmAYNUudcfE0NERvs1q3s2GOKtI5+DuhmbZp4EiQvEcYiCrrGenS3kEKJHAYBvsNxkVrH2niPfjYwGSOuCz2hbLZrJEA4L7OHbccCKAKH5m9U/TX3RsuijVqvH3mIqTmj/Sj1q6vvFcV0=
- In-reply-to: <f8gnpp$b2f$1@xxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <f8gnpp$b2f$1@xxxxxxxxxxxxx>
On 7/28/07, pol <linux_milano@xxxxxxxx> wrote:
>
> To tell real files from symbolic links, so as to separate the filename from
> the path to be able to change to the actual file the link is pointing to,
On a linux system, at least, you can do something like this:
~>cd /tmp
/tmp>touch a
/tmp>ln -s a b
/tmp>ln -s b c
/tmp>ln -s c d
/tmp>readlink -f a
/tmp/a
/tmp>readlink -f b
/tmp/a
/tmp>readlink -f c
/tmp/a
/tmp>readlink -f d
/tmp/a
so, you should be able to just use
file=$(readlink -f "$file")
assuming you'd like to resolve links recursively, so that a link to a
link to a file resolves to the file and not the middle link.
~Matt
Messages sorted by:
Reverse Date,
Date,
Thread,
Author