Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Finding symbolic links that are outside a tree (comp.unix.shell)
- X-seq: zsh-users 8977
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Finding symbolic links that are outside a tree (comp.unix.shell)
- Date: Tue, 07 Jun 2005 17:39:00 +0000
- In-reply-to: <aib4t06xwben.opeowl6vwzgn.dlg@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <aib4t06xwben.opeowl6vwzgn.dlg@xxxxxxxxxx>
On Jun 7, 5:01pm, Thorsten Kampe wrote:
} Subject: Finding symbolic links that are outside a tree (comp.unix.shell)
}
} So can this be done with zsh globbing? I couldn't get any further as
} "print -l **/*(@)" which prints only symbolic links but doesn't do
} anything for "that are outside a tree".
I'm not entirely sure I understand the question, but I *think* the
answer is to begin with something like
function follow () {
stat -A reply +link $REPLY
if [[ $reply != /* ]]
then reply=( $PWD/$reply )
fi
}
zmodload -i zsh/stat
declare -a links
links=( **/*(@+follow) )
links=( ${links#$PWD/} )
integer n=${(@)#${(s:/:)PWD}}
Then walk the $links array and print every entry that begins with a slash
or has more leading ../ than the value of $n.
For older versions of zsh you need
links=( **/*(@e:follow:) )
instead of the +follow shorthand.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author