annotate tools/filters/tailWrapper.pl @ 0:9071e359b9a3

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:37:19 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 #! /usr/bin/perl -w
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 use strict;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 use warnings;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6 # a wrapper for tail for use in galaxy
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 # lessWrapper.pl [filename] [# lines to show] [output]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 die "Check arguments" unless @ARGV == 3;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10 die "Line number should be an integer\n" unless $ARGV[1]=~ m/^\d+$/;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 open (OUT, ">$ARGV[2]") or die "Cannot create $ARGV[2]:$!\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 open (TAIL, "tail -n $ARGV[1] $ARGV[0]|") or die "Cannot run tail:$!\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 while (<TAIL>) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 print OUT;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 close OUT;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 close TAIL;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19