Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4035574
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:06:55+00:00 2026-05-20T12:06:55+00:00

How can I find a file, user owned by tree and group owned by

  • 0

How can I find a file, user owned by tree and group owned by tree? And how can I find a whole directory inside which files are owned by tree?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:06:56+00:00Added an answer on May 20, 2026 at 12:06 pm

    The File::Find module is a standard Perl module (i.e., it is available on all installations of Perl). You can use File::Find to go through a directory tree and search for the file you want.

    To use, you create a wanted subroutine that parses the files, then have the find subroutine include that wanted routine in its call. The File::Find module is a bit klutzy because it was originally only meant to use for the find2perl command.

    Here’s some completely untested code. Notice that you do yucky stuff like using global variables and package variables. It’s one of the reasons I don’t like File::Find.

    use File::Find;
    our $myUid = getpwnam('tree');
    our $muGid = getgrnam('tree');
    find (\&wanted, @dirList);
    
    sub wanted {
        my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($File::Find::name);
        next if (not -f $File::Find::name);
        next if ($uid != $myUid);
        next if ($gid != $myGid);
        print qq(File "$File::Find::name" is owned by group 'tree' and user 'tree'\n);
    }
    

    I wrote my own File::Find called File::OFind because it’s more object oriented. You can get that from here. It’s a bit easier to understand. (Again, completely untested):

    use File::OFind;
    # Really should test if these return something
    my $myUid = getpwnam('tree');
    my $muGid = getgrnam('tree');
    
    # Create your directory search object
    my $find = File::OFind->new(STAT => 1, $directory);
    
    # Now keep looping and examining each file
    while($find->Next) {
       next if ($find->Uid != $myUid);
       next if ($find->Gid != $myGid);
       next if ($find->Type ne "f");   #Is this a file?
       print $find->Name . " is owned by group and user tree\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can File::Find::Rule be used to determine if a directory is writeable by a given
Where can I find a file format spec, or guidance for parsing, .suo files?
Given a function, let's say atoi, how can I find the header file I
How can I find extended ASCII characters in a file using Perl? Can anyone
Where can I find phonegap-1.3.0.js file iOS. In package it is there for Android.
How can I find out the name of the fields in a PDF file
I got an hotfix from microsoft (msu file). How can i find the contents
How do you underline a text in an XML file? I can't find an
How can I use the autoloader to find the class file 'templater' that lives
I can't for the life of me find any decent explanation of the [file]:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.