File: tarlist

package info (click to toggle)
fex 20200429-1
  • links: PTS, VCS
  • area: non-free
  • in suites: sid
  • size: 3,532 kB
  • sloc: perl: 32,103; sh: 410; javascript: 53; makefile: 42
file content (29 lines) | stat: -rwxr-xr-x 668 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl -w

# show sorted content of tar archive

$0 =~ s:.*/::;

$usage = "usage: $0 file.tar\n";
die $usage if scalar(@ARGV) != 1 or "@ARGV" =~ /^-/;

$file = shift @ARGV;

die "$0: \"$file\" does not exist\n"        unless -e $file;
die "$0: \"$file\" is not a regular file\n" unless -f $file;
die "$0: \"$file\" is not readable\n"       unless -r $file;

open $list,'-|',qw'tar tvf',$file or exit $?;

while (<$list>) {
  if (/(.+?) (.+?) +(\d+) (\d\d\d\d-\d\d-\d\d \d\d:\d\d) (.+)/) {
    $p{$5} = $1;
    $u{$5} = $2;
    $s{$5} = $3;
    $d{$5} = $4;
  }
}

foreach $f (sort keys %p) {
  printf "%s %-17s %13d %s %s\n",$p{$f},$u{$f},$s{$f},$d{$f},$f;
}