Afficher un message
Vieux 12/09/2007, 21h37   #5
Frank J. Schima
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Getting line count of a text file

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



  Réponse avec citation
 
Page generated in 0,06355 seconds with 9 queries