Re: Getting line count of a text file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Gang,


On Sep 12, 2007, at 1:58 PM, bruce wrote:

if you're going to do the system approach, go ahead and use awk/cut...

wc -l foo.txt | awk -F' ' '{print $1}'

should work assuming you're on linux.....

I have solved the problem with this approach. Thanks for all the suggestions.

FYI, it was a (very) minor pain to make that into a string. I ended up using this:

$count = system("wc -l /path/to/myfile.txt | awk -F' ' '{print " . '$' . "1}'");

I didn't need to escape anything because the file was hardcoded - no user input.


Cheers,
Frank Schima
Foraker Design
<http://www.foraker.com>
303-449-0202



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux