7 td-trans-ls - Transform ls(1) output into fix number of TAB-delimited columns.
15 Supported ls(1) options which affect its output format:
19 =item --human-readable
25 =item --time-style={iso,long-iso,full-iso}
39 =item --time-style=locale
45 no if ($] >= 5.018), 'warnings' => 'experimental::smartmatch';
46 do '/usr/lib/tool/perl5/tabdata/common.pl' or die "$@";
49 $first_line = <STDIN
>;
50 if($first_line !~ /^\S+ \d+$/)
53 $first_line =~ /^(.+):$/;
54 $current_directory = $1;
55 # skip the "total 123" line
59 @Headers = qw
/INODE MODE LINKS OWNER GROUP SIZE MAJOR MINOR DATETIME NAME SYMLINKTARGET/;
60 push @Headers, 'DIRECTORY' if $recursive_mode;
62 print join($FS, @Headers).$/;
64 $mode_links_owner_group = qr/(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/;
66 # update supported --time-style options in the documentation
67 $datetime = qr/((?:\d\d\d\d-)?\d\d-\d\d \d\d:\d\d(?::\d\d(?:\.\d+)? [\d+-]+)?)/;
71 die "can not parse: $_[0]\n";
84 /^(.+):$/ or die "a directory introduction expected, not this: $_\n";
85 $current_directory = $1;
86 # skip the next "total 123" line
99 @Fields = /^$mode_links_owner_group\s+()([^,]+),\s*(\S+)\s+$datetime\s+(.+)()$/ or parse_error
$_;
103 @Fields = /^$mode_links_owner_group\s+(\S+)()()\s+$datetime\s+(.+?) -> (.+)$/ or parse_error
$_;
107 @Fields = /^$mode_links_owner_group\s+(\S+)()()\s+$datetime\s+(.+)()$/ or parse_error
$_;
110 unshift @Fields, $inode;
111 push @Fields, $current_directory if $recursive_mode;
113 print join($FS, @Fields).$RS;