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 -->
  #2 (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
Your code already assigns the number of lines to the variable $= (which is a really obscure thing to do anyway); just change that to whatever variable you really want.

More generally, if you read a file into an array, then @array in scalar context will tell you how many lines are in that array. Presumably you want to do something more with the file than just count the number of lines in it.