Skip to content

Unclassified: Perl Script to Count the Rows of a file SEC=UNCLASSIFIED

July 2, 2009

Copy the following to a text file, update the file_name with the name of the file that you want to count the rows of and save it as Row_Count.PL.

#!/bin/perl

open(INFILE, "<g:\File_Name.TXT") or die "Can’t open input.txt: $!";

open(OUTFILE, ">g:\File_Name_count.TXT") or die "Can’t open output.txt: $!";

$count = 0;

$line = <INFILE>;

while ($line ne "") {

$count = $count +1;

$line = <INFILE>; }

print OUTFILE "$count";

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: