G'day GillSans,

Welcome to the monastery.

I don't have the lsattr command on my OS; however, I can roughly emulate what I think you need. The ls -i command gives "inode filename"; I believe your lsattr command gives "attr filename". Those are close enough to show the technique. In the code below, I've just used splice to force a missing entry such as you get when you encounter a link.

$ perl -Mstrict -Mwarnings -E ' chomp(my @lsl = qx{ls -l | tail -3}); chomp(my @lsi = qx{ls -i | tail -3}); splice @lsi, 1, 1; my $lsi_index = 0; for (@lsl) { my $file = (split / /)[-1]; my $pos = index $lsi[$lsi_index], $file; if ($pos == -1) { say " N/A ", $_; } else { say substr($lsi[$lsi_index++], 0, $pos), $_; } } ' 44060626 -rw-r--r-- 1 ken staff 0 10 Sep 15:02 zz1 N/A -rw-r--r-- 1 ken staff 0 10 Sep 15:02 zz2 44060628 -rw-r--r-- 1 ken staff 0 10 Sep 15:03 zz3

I think you should be able to adapt that to your needs.

Here's what those two commands would normally output on my OS:

$ ls -l | tail -3; ls -i | tail -3 -rw-r--r-- 1 ken staff 0 10 Sep 15:02 zz1 -rw-r--r-- 1 ken staff 0 10 Sep 15:02 zz2 -rw-r--r-- 1 ken staff 0 10 Sep 15:03 zz3 44060626 zz1 44060627 zz2 44060628 zz3

Update: I had extra whitespace. Removed "join " " =>" which got rid of the extra space, and serendipitously simplified the code example.

-- Ken


In reply to Re: STDERR, preserve order of by kcott
in thread STDERR, preserve order of by GillSans

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.