Re: Getting line count of a text file
| From: | Frank J. Schima | Date: | Wed, 12 Sep 2007 20:37:45 +0000 |
| Subject: | Re: Getting line count of a text file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-262055@lists.php.net to get a copy of this message | ||
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