File: first-and-last-lines-via-process-pipe.pl

package info (click to toggle)
libfile-next-perl 1.18-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 260 kB
  • sloc: perl: 996; ansic: 21; makefile: 3; javascript: 2
file content (21 lines) | stat: -rw-r--r-- 300 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env perl

use strict;
use warnings;

use File::Next;

my ( $input ) = @ARGV;

my $files = File::Next::files( $input );
my $file  = $files->();
if ( open my $f, '<', $file ) {
    my @lines = <$f>;
    print $lines[0];
    print $lines[-1];
    close $f;
    exit 0;
}
else {
    exit 1;
}