Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- @files = ();
- if($ARGV[0] =~ /^-[0-9]+$/){
- $n = $ARGV[0];
- $n =~ s/-//g; #removes - from -n
- shift @ARGV;
- }else {
- $n = 10;
- }
- foreach $arg (@ARGV){
- if ($arg eq "--version"){
- print "$0: version 0.1\n";
- exit(0);
- #handle other options
- }else{
- push @files, $arg;
- }
- }
- foreach $f (@files){
- open(F,"<$f") or die "$0: Can't open $f:$!\n";
- #process F
- #...
- if(@files >1){
- print "==> $f <==\n";
- }
- $num_lines = `cat < $f | wc -l | egrep -o "[0-9]+"`;
- # $num_lines2 = split " ", $num_lines;
- # print "num lines = $num_lines\n\n";
- $g = 1;
- while($line = <F>){
- if($g > ($num_lines - $n)){
- print $line;
- }
- $g++;
- }
- close(F);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement