I have a situation where I need to track a file through directories on the same files system.

Originally I was going to use File::Find to locate the files, store the information in a hash, wait a little bit do the same routine again and compare the two hashes for differences. This seemed like to much IO just to see if a file moved from one directory to another.

Enter my next idea. Using the cpan module 'ReadDir' I can get the inode numbers of the files in the directory I am using as my starting place for the sake of monitoring. I now have a list of inode numbers and what I would like to do is be able to find the path of a file with inode number XXXXXXX.

This would keep me from having to do all the IO of locating the file every time. I could swear I saw something like this a few years ago. It was a set of shell utilities. One would give you the inode number of a file (note, not ls -i, it was an actual utility) and the other would tell you the file an inode pointed to.

Unfortunately, I cannot recall what these were. Does anyone recall these two utilities or have another way to quickly get the path of a file from the inode number?

TIA, Chad.


In reply to locate path to a file from inode number by gnu@perl

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.