in reply to Re^4: Restrict file search within current filessystem using wanted subroutine
in thread Restrict file search within current filessystem using wanted subroutine

Hi Anonymous,

"All flavours of Unix" is a very broad question that is difficult to answer generally, but FWIW I believe stat(2) is a relatively well-standardized function. What specific flavors of Unix do you want to run your script on which you are concerned about?

Also, have a look at perlport, which lists known issues with stat across various platforms.

Hope this helps,
-- Hauke D

  • Comment on Re^5: Restrict file search within current filessystem using wanted subroutine

Replies are listed 'Best First'.
Re^6: Restrict file search within current filessystem using wanted subroutine
by Anonymous Monk on May 12, 2016 at 10:41 UTC
    Hi Hauke,

    Trying to run it on Linux, AIX, HP-UX and Solaris.

    --madparu

      Hi madparu,

      Unfortunately I don't know enough about all of those systems to give you a good answer. But since AIX, HP-UX and Solaris are (in various versions) POSIX certified, and none of perlport, perlsolaris, perlhpux, or perlaix seem to mention any issues with stat on those systems, I'd make the educated guess that the "dev" field of stat should work the same on all of those OSes. Update: Just to be clear, I don't mean that the device IDs will be the same across those OSes - what I mean is that I think the above method of detecting file system boundaries should work on each of those OSes.

      Of course, you can just try it out on each system:

      perl -le 'print "$_\tdev=",(stat)[0] for @ARGV' /var /var/log

      Regards,
      -- Hauke D

        Hi Hauke,

        I managed to run the script itself on all the flavours and it works fine. thank you!!

        --madparu
        Hi Hauke,

        I tried excluding a specific file (say /var/log/test.out) as below:

        return if ($File::Find::name =~ test.out);

        This seems to work. but this might exclude test.out if it finds in any other filesystem. so tried to use the below code but doesn't work.

        return if ($File::Find::name =~ /^\/var\/log\/lastlog);

        Whats the best way to exlcude test.out from /var/log?