Jun 30, 2005 #1 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
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
Jun 30, 2005 1 #3 PHV MIS Nov 8, 2002 53,708 FR 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 Upvote 0 Downvote
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
Jul 8, 2005 1 #4 feherke Programmer Aug 5, 2002 9,541 RO Hi Code: nr=`grep -c "" /path/to/file` Code: nr=`sed -n '$=' /path/to/file` Feherke. http://rootshell.be/~feherke/ Upvote 0 Downvote
Hi Code: nr=`grep -c "" /path/to/file` Code: nr=`sed -n '$=' /path/to/file` Feherke. http://rootshell.be/~feherke/
Jul 9, 2005 Thread starter #5 Michael42 Programmer Oct 8, 2001 1,454 US Thanks all. Your posts wre very useful. -Michael42 Upvote 0 Downvote