* Re: finding symlinks without target
[not found] <199801231642.IAA27762@shell10.ba.best.com>
@ 1998-01-23 17:10 ` Bart Schaefer
1998-01-23 17:46 ` Bruce Stephens
0 siblings, 1 reply; 11+ messages in thread
From: Bart Schaefer @ 1998-01-23 17:10 UTC (permalink / raw)
To: ZShell Users
On Jan 23, 4:42pm, Bruce Stephens wrote:
} Subject: Re: finding symlinks without target
}
} schaefer@brasslantern.com said:
} > (Why isn't there a glob qualifier to chase links? **/*(@^.,@^/) would
} > appear to be perfect, but doesn't work.)
}
} There is, isn't there. The - seems to be right, almost.
Indeed. I missed that one when scanning the zsh info (probably because
I was looking for a description that used the word "chase" as in the
CHASE_LINKS option).
} How about
} **/*(@-^.,@-^/)
}
} Meaning those symbolic links whose referents aren't files or directories?
I should have realized before that this won't work, because that's an
-inclusive- "or" and what's wanted is an -exclusive- "or". However,
this appears to do the trick:
echo **/*(@-^./=%p)
All symlinks that don't point to files, directories, sockets, devices,
or named pipes. Whew.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: finding symlinks without target
1998-01-23 17:10 ` finding symlinks without target Bart Schaefer
@ 1998-01-23 17:46 ` Bruce Stephens
0 siblings, 0 replies; 11+ messages in thread
From: Bruce Stephens @ 1998-01-23 17:46 UTC (permalink / raw)
To: Bart Schaefer; +Cc: ZShell Users
schaefer@brasslantern.com said:
> However, this appears to do the trick:
> echo **/*(@-^./=%p)
> All symlinks that don't point to files, directories, sockets, devices,
> or named pipes. Whew.
It's zany, sure. I'm tempted to suggest a special non-existent file
qualifier, which would expand to files that don't exist, which you could then
use in this context, but that's probably a bit expensive if you use it in any
other context. And a special combination qualifier of ./=%p is probably not
useful enough to add either. So Bart's solution is probably as simple as it's
going to get.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: finding symlinks without target
@ 1998-01-26 4:41 Paul Lew
0 siblings, 0 replies; 11+ messages in thread
From: Paul Lew @ 1998-01-26 4:41 UTC (permalink / raw)
To: zsh-users
In message <19980123154701.05885@math.fu-berlin.de>, Sven Guckes writes:
>Hi!
>
>Problem:
> Find (and print) all symbolic links without a target within the
> current dirtree.
The old zsh (dont remember version) will show bad symbolic links with
an '&' appended instead of '@' when showing partial completed
filenames. What happen to that code? I found I miss that feature.
Will come handy in this case.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: finding symlinks without target
1998-01-23 14:47 Sven Guckes
` (2 preceding siblings ...)
1998-01-23 16:00 ` Bart Schaefer
@ 1998-01-23 17:51 ` Peter Williams
3 siblings, 0 replies; 11+ messages in thread
From: Peter Williams @ 1998-01-23 17:51 UTC (permalink / raw)
To: ZShell Users
In message <19980123154701.05885@math.fu-berlin.de>, Sven Guckes writes:
>Hi!
>
>Problem:
> Find (and print) all symbolic links without a target within the
> current dirtree.
Why not implement it as a function with perl:
badsyms () {
perl -e '{
require "find.pl";
sub wanted { !stat($_) && print("$name\n") }
&find(@ARGV);
}' $*
}
Peter Williams <peter.williams@jpl.nasa.gov>
------------------ SITUATION: New Account Creation -------------------
ADMINISTRATIVE FASCIST: Puts new account policy in motd. Since
people without accounts cannot read the motd, nobody ever fulfills
the bureaucratic requirements; and so, no new accounts are ever
created.
-- Stephan Zielinski, "KNOW YOUR UNIX SYSTEM ADMINISTRATOR"
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: finding symlinks without target
1998-01-23 16:00 ` Bart Schaefer
1998-01-23 16:42 ` Bruce Stephens
@ 1998-01-23 16:47 ` Peter Williams
1 sibling, 0 replies; 11+ messages in thread
From: Peter Williams @ 1998-01-23 16:47 UTC (permalink / raw)
To: ZShell Users
In message <980123080024.ZM16631@candle.brasslantern.com>, "Bart Schaefer" writ
es:
> file **/*(D@) | fgrep broken
>
>(You may need to change the grep if you're not using GNU `file`.)
>
>Oh, you want it all in zsh?
>
> for i in **/*(D@); [[ -f $i || -d $i ]] || echo $i
>
>But I think the pipe to fgrep would be faster. (Why isn't there a glob
>qualifier to chase links? **/*(@^.,@^/) would appear to be perfect, but
>doesn't work.)
You could also implement it as a function with perl:
badsyms () {
perl -e '{
require "find.pl";
sub wanted { !stat($_) && print("$name\n") }
&find(@ARGV);
}' $*
}
However, this seems a bit slower than M. Schaefer's solutions above.
Peter Williams <peter.williams@jpl.nasa.gov>
------------------ SITUATION: New Account Creation -------------------
ADMINISTRATIVE FASCIST: Puts new account policy in motd. Since
people without accounts cannot read the motd, nobody ever fulfills
the bureaucratic requirements; and so, no new accounts are ever
created.
-- Stephan Zielinski, "KNOW YOUR UNIX SYSTEM ADMINISTRATOR"
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: finding symlinks without target
1998-01-23 16:00 ` Bart Schaefer
@ 1998-01-23 16:42 ` Bruce Stephens
1998-01-23 16:47 ` Peter Williams
1 sibling, 0 replies; 11+ messages in thread
From: Bruce Stephens @ 1998-01-23 16:42 UTC (permalink / raw)
To: Bart Schaefer; +Cc: ZShell Users
schaefer@brasslantern.com said:
> (Why isn't there a glob qualifier to chase links? **/*(@^.,@^/) would
> appear to be perfect, but doesn't work.)
There is, isn't there. The - seems to be right, almost. How about
**/*(@-^.,@-^/)
Meaning those symbolic links whose referents aren't files or directories? On
the other hand, I'll bet this won't work, because the property of existence is
probably required when globbing. The question is a good one though: there
ought to be a way of doing this, and it probably ought to be an example in the
manual, because it's a common enough task, and it would be cool to have a
one-liner for small trees.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: finding symlinks without target
1998-01-23 14:47 Sven Guckes
1998-01-23 15:12 ` Bernd Eggink
1998-01-23 15:26 ` Bruce Stephens
@ 1998-01-23 16:00 ` Bart Schaefer
1998-01-23 16:42 ` Bruce Stephens
1998-01-23 16:47 ` Peter Williams
1998-01-23 17:51 ` Peter Williams
3 siblings, 2 replies; 11+ messages in thread
From: Bart Schaefer @ 1998-01-23 16:00 UTC (permalink / raw)
To: Sven Guckes, ZShell Users
On Jan 23, 3:47pm, Sven Guckes wrote:
} Subject: finding symlinks without target
}
} Find (and print) all symbolic links without a target within the current
} dirtree.
file **/*(D@) | fgrep broken
(You may need to change the grep if you're not using GNU `file`.)
Oh, you want it all in zsh?
for i in **/*(D@); [[ -f $i || -d $i ]] || echo $i
But I think the pipe to fgrep would be faster. (Why isn't there a glob
qualifier to chase links? **/*(@^.,@^/) would appear to be perfect, but
doesn't work.)
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: finding symlinks without target
@ 1998-01-23 15:34 Niall Smart
0 siblings, 0 replies; 11+ messages in thread
From: Niall Smart @ 1998-01-23 15:34 UTC (permalink / raw)
To: Sven Guckes, ZShell Users
On Jan 23, 3:47pm, Sven Guckes wrote:
} Subject: finding symlinks without target
> Hi!
>
> Problem:
> Find (and print) all symbolic links without a target within the current dirtree.
>
> Anyone hints?
This is an abuse of your shell, there are already many C variants of
this, though I can't remember any of their names. If you were really
desperate, you could hack something up with zsh and find. Eg.
find . -type l -exec myscript.zsh {} \; etc etc.
Niall
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: finding symlinks without target
1998-01-23 14:47 Sven Guckes
1998-01-23 15:12 ` Bernd Eggink
@ 1998-01-23 15:26 ` Bruce Stephens
1998-01-23 16:00 ` Bart Schaefer
1998-01-23 17:51 ` Peter Williams
3 siblings, 0 replies; 11+ messages in thread
From: Bruce Stephens @ 1998-01-23 15:26 UTC (permalink / raw)
To: ZShell Users
guckes@math.fu-berlin.de said:
> Find (and print) all symbolic links without a target within the
> current dirtree.
For big dirtrees, this is probably a job for find. I can't see immediately
how to do it in zsh.
**/*(@) gives the list of symbolic links, and **/*(-@) gives the list of
symbolic links with targets which do exist. Clearly, from this one can
calculate the list of symbolic links which don't have existing targets, but
there ought to be an easier way of doing it.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: finding symlinks without target
1998-01-23 14:47 Sven Guckes
@ 1998-01-23 15:12 ` Bernd Eggink
1998-01-23 15:26 ` Bruce Stephens
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Bernd Eggink @ 1998-01-23 15:12 UTC (permalink / raw)
To: Sven Guckes; +Cc: ZShell Users
Sven Guckes wrote:
>
> Hi!
>
> Problem:
> Find (and print) all symbolic links without a target within the current dirtree.
>
> Anyone hints?
Not too elegant, but it works:
for d in *(@); do cat $d >/dev/null 2>&1 || print $d; done
Bernd
--
Bernd Eggink
Regionales Rechenzentrum der Uni Hamburg
eggink@rrz.uni-hamburg.de
http://www.rrz.uni-hamburg.de/eggink/BEggink.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* finding symlinks without target
@ 1998-01-23 14:47 Sven Guckes
1998-01-23 15:12 ` Bernd Eggink
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Sven Guckes @ 1998-01-23 14:47 UTC (permalink / raw)
To: ZShell Users
Hi!
Problem:
Find (and print) all symbolic links without a target within the current dirtree.
Anyone hints?
Sven
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~1998-01-26 5:05 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <199801231642.IAA27762@shell10.ba.best.com>
1998-01-23 17:10 ` finding symlinks without target Bart Schaefer
1998-01-23 17:46 ` Bruce Stephens
1998-01-26 4:41 Paul Lew
-- strict thread matches above, loose matches on Subject: below --
1998-01-23 15:34 Niall Smart
1998-01-23 14:47 Sven Guckes
1998-01-23 15:12 ` Bernd Eggink
1998-01-23 15:26 ` Bruce Stephens
1998-01-23 16:00 ` Bart Schaefer
1998-01-23 16:42 ` Bruce Stephens
1998-01-23 16:47 ` Peter Williams
1998-01-23 17:51 ` Peter Williams
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).