I need to search through a large structure with saved web pages and subsidiary files, saved from firefox, most often just to find the most recently updated page from its time stamp. I prefer to use the perl stat() function, rather than the ls command as I have been using:

james@tibrogargan:~/devel/find/testdirs$ find . -type f -exec ls -l -- +time-style=+%Y%m%d {} \; -rw-rw-r-- 1 james james 7 20221013 ./d2/d2_3/f2_3_1 -rw-rw-r-- 1 james james 13 20221013 ./d2/d2_2/f2_2_2 -rw-rw-r-- 1 james james 8 20221013 ./d2/d2_2/f2_2_1 -rw-rw-r-- 1 james james 13 20221013 ./d2/f2_2 -rw-rw-r-- 1 james james 0 20221012 ./d1/d3_3/f1 -rw-rw-r-- 1 james james 0 20221012 ./d1/d1_1/f1 -rw-rw-r-- 1 james james 0 20221012 ./d1/d1_1/f3 -rw-rw-r-- 1 james james 0 20221012 ./d1/d1_1/f2 -rw-rw-r-- 1 james james 0 20221012 ./d1/d1_2/f1 -rw-rw-r-- 1 james james 0 20221012 ./d1/d1_2/f3 -rw-rw-r-- 1 james james 0 20221012 ./d1/d1_2/f2

I want to transform the above in many ways, including placing the file basename at the start, etc., etc., roughly as follows:

f2_3_1 7 20221013 ./d2/d2_3/ <directoryInodeNumber> ...

The program, I have written as my first step towards accomplishing this (less many comments and debugging statements) is:

#!/usr/bin/perl use Cwd qw(cwd); my $wDirectory = cwd; my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtim +e, $ctime, $blksize, $blocks) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0); open(README, "find $wDirectory -type f |") or die "Can't run program: +$!\n"; while(<README>) { $output = $_; ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mti +me, $ctime, $blksize, $blocks) = stat("$output"); print("stats "); print ("dev: $dev, ino: $ino, mode: $mode, nlink: $nlink, uid: $ui +d, gid: $gid, rdev: $rdev, size: $size, atime: $atime, mtime: $mtime, + ctime: $ctime, blksize: $blksize, blocks: $blocks"); print("]\n"); } close(README);

But when I execute the program I get no data whatsoever from the stat() function:

james@tibrogargan:~/devel/find/testdirs$ ~/devel/perl/findLsiCleaned.p +l stats dev: , ino: , mode: , nlink: , uid: , gid: , rdev: , size: , ati +me: , mtime: , ctime: , blksize: , blocks: ] stats dev: , ino: , mode: , nlink: , uid: , gid: , rdev: , size: , ati +me: , mtime: , ctime: , blksize: , blocks: ] stats dev: , ino: , mode: , nlink: , uid: , gid: , rdev: , size: , ati +me: , mtime: , ctime: , blksize: , blocks: ] stats dev: , ino: , mode: , nlink: , uid: , gid: , rdev: , size: , ati +me: , mtime: , ctime: , blksize: , blocks: ] stats dev: , ino: , mode: , nlink: , uid: , gid: , rdev: , size: , ati +me: , mtime: , ctime: , blksize: , blocks: ] stats dev: , ino: , mode: , nlink: , uid: , gid: , rdev: , size: , ati +me: , mtime: , ctime: , blksize: , blocks: ] stats dev: , ino: , mode: , nlink: , uid: , gid: , rdev: , size: , ati +me: , mtime: , ctime: , blksize: , blocks: ] stats dev: , ino: , mode: , nlink: , uid: , gid: , rdev: , size: , ati +me: , mtime: , ctime: , blksize: , blocks: ] stats dev: , ino: , mode: , nlink: , uid: , gid: , rdev: , size: , ati +me: , mtime: , ctime: , blksize: , blocks: ] stats dev: , ino: , mode: , nlink: , uid: , gid: , rdev: , size: , ati +me: , mtime: , ctime: , blksize: , blocks: ] stats dev: , ino: , mode: , nlink: , uid: , gid: , rdev: , size: , ati +me: , mtime: , ctime: , blksize: , blocks: ]

Can anyone see why my script does not work?

Thank you for your attention.


In reply to stat function used with linux find gives me no data by daggett

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.