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 | [reply] [d/l] |
| [reply] |
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?
| [reply] |
Hi Anonymous,
The issue is that if you tell your script to search a relative pathname (such as the default "."), then $File::Find::name will not be an absolute pathname either. Have a look at the Basic debugging checklist - this tells you that you should print your values, such as print $File::Find::name;, and you can find this out for yourself.
One way to fix this: 1. At the top of your script, add "use File::Spec::Functions qw/rel2abs/;" (see the function rel2abs in File::Spec), and 2. replace "shift || '.'" with "rel2abs(shift || '.')" - now all your search paths and therefore $File::Find::name should be absolute pathnames.
If it's just that one specific file, a regex is not necessary and you can use an exact match to exclude it: return if $File::Find::name eq '/var/log/test.out';
Hope this helps, -- Hauke D
(P.S. I'm assuming that it's obvious that the regex /^\/var\/log\/lastlog/ won't help in excluding a file named test.out and that you just got your examples mixed up.)
| [reply] [d/l] [select] |