Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Look for ~*/.netscape/ dirs

by merlyn (Sage)
on Apr 13, 2001 at 02:36 UTC ( [id://72222]=CUFP: print w/replies, xml ) Need Help??

Ever wanted to look for the .netscape directories of everyone on a system? Simple enough if you know the right pieces to squish together. This is a great list for searching as input to File::Find.
my @dirs = grep -d, do { my %list; my @item; $list{$item[7]}++ while @item = getpwent; map "$_/.netscape", keys %list; };

Replies are listed 'Best First'.
Re: Look for ~*/.netscape/ dirs
by Dominus (Parson) on Apr 13, 2001 at 03:49 UTC
    The original poster (on clp.misc) was only looking for files that would match /^(li|)prefs.js$/, and it turned out he didn't actually need a recursive search. So I suggested that he avoid File::Find completely:
    while (@data = getpwent) { my $dir = $data[7]; # home directory push @files, grep -e, "$dir/.netscape/prefs.js", "$dir/.netscape/liprefs.js"; }
Re: Look for ~*/.netscape/ dirs
by strredwolf (Chaplain) on Apr 14, 2001 at 10:09 UTC
    I think this would work better. Unfortunately, it doesn't use perl...

    find ~/.netscape -name prefs.js -o -name liprefs.js -print

    --
    $Stalag99{"URL"}="http://stalag99.keenspace.com";

      You missed the star after the tilde (which doesn't really work) {grin}. My solution looks in all home directories. Yours looks only in your own.

      -- Randal L. Schwartz, Perl hacker

        From your snippet, I couldn't see if it actually did go through all the homes (getpwent's worthy, but still, where's the full search?)

        Of course, there's...

        open(IN,"</etc/passwd"); while(<IN>) { chomp; next unless(/^([^:]+):/); $names=`find ~$1/.netscape -name prefs.js -o -name liprefs.js -pri +nt`; @names=split /\n/, $names; push @files, @names; }

        --
        $Stalag99{"URL"}="http://stalag99.keenspace.com";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-16 11:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found