Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Unix Administration: Finding symbolic links with perl and *nix

by frag (Hermit)
on Nov 14, 2001 at 06:26 UTC ( [id://125210]=note: print w/replies, xml ) Need Help??


in reply to Unix Administration: Finding symbolic links with perl and *nix

Well, TMTOWTDI, but I can't say that this will keep me from shying away from /.{0,3}sh/ scripts! Here's one Perl way to do it, courtesy of the Cookbook:
#!/usr/bin/perl -w use File::Find; find(\&wanted, shift || '.'); sub wanted { -l and not -e and print "bogus link: $File::Find::name\n"; }

-- Frag.
--
"Just remember what ol' Jack Burton does when the earth quakes, the poison arrows fall from the sky, and the pillars of Heaven shake. Yeah, Jack Burton just looks that big old storm right in the eye and says, "Give me your best shot. I can take it."

Replies are listed 'Best First'.
Re: Re: Unix Administration: Finding symbolic links with perl and *nix
by mattr (Curate) on Nov 15, 2001 at 12:31 UTC
    Yep, you're right. Perl *does* rule.

    My motivation really came about when wrestling with a mixture of different ticks from a shell for loop and an awk command in that article.. this didn't work:

    # for i in 'file * | grep "ASCII C program text" | \ awk -F: '{print $1}'`; do mv $i $i.c; done
    The different ticks are tricky. You can try it by erasing "C program text" and changing mv to echo. Hmm, still not sure if that should work or not.

    Anyway, now instead of always relying on perl -pi (which also rules, let it be said) I feel personally a little more comfortable with piped operations on lists of files on the command line. Though I find that some shell tools pad output to both left and right justify at the same time.. this is a bad thing and Perl is still what I use for gardening.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://125210]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-03-28 10:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found