Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Total Lines in a File 3

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello,

On Sun Solaris 8 using a Bourne shell script I need to set the value of a variable to the total lines contained in a text file.

How can I get the total lines a text file contains?

Thanks,

Michael42
 
One way:
CountOfLines=`nawk 'END{print NR}'` /path/to/file
You may also play with wc -l

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks all.

Your posts wre very useful. :)

-Michael42
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top