in reply to STDERR, preserve order of

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