The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 05-20-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652

Code:
my $f = "sample_file_name";
open (F, $f) || die "Could not open $f: $!\n";
my @f = <F>;
close F;
my $lines = @f;

Incidentally, in the shell script, if you use redirection, you don't need to use cut to get rid of the file name.


Code:
no_lof_line=`wc -l <sample_file_name`

And of course, the temporary file is also quite unnecessary, either way.