<?php
$fileName = './chatfile.txt';
function yieldFile($fileName)
{
if (!$fileHandle = fopen($fileName, 'r'))
return;
while (FALSE !== $line = fgets($fileHandle))
yield $line;
fclose($fileHandle);
}
$lines = [];
foreach (yieldFile($fileName) as $line)
{
if (!isset($lines[$line]))
$lines[$line] = 1;
else
++$lines[$line];
}
foreach ($lines as $text => $times)
{
if ($times == 1)
echo trim($text) . PHP_EOL;
else
echo trim($text) . " (x{$times})" . PHP_EOL;
}
?>
php logFileParser.php > logFileCondensed.txt
Apr 09 05:26:20 LFS : 0.6H
Apr 09 05:26:35 Can't open : WE_ADS2.jpg (x5)
Apr 09 05:26:36 Can't open : WE_ADS1.jpg (x6)
Apr 09 05:26:36 Can't open : WE_ADS2.jpg (x9)
Apr 09 05:26:37 Can't open : WE_ADS1.jpg (x3)
Apr 09 05:26:38 Can't open : WE_ADS1.jpg (x9)
Apr 09 05:26:39 Can't open : WE_ADS1.jpg (x8)
Apr 09 05:26:40 Can't open : WE_ADS1.jpg (x9)
Apr 09 05:26:41 Can't open : WE_ADS1.jpg (x9)
Apr 09 05:26:42 Can't open : WE_ADS1.jpg (x8)
Apr 09 05:26:43 Can't open : WE_ADS1.jpg (x9)
Apr 09 05:26:44 Can't open : WE_ADS1.jpg (x8)
Apr 09 05:26:45 Can't open : WE_ADS1.jpg (x7)
Apr 09 05:26:45 Can't open : WE_ADS3.jpg (x15)
Apr 09 05:26:46 Can't open : WE_ADS3.jpg (x62)
Apr 09 05:26:47 Can't open : WE_ADS3.jpg (x62)
Apr 09 05:26:48 Can't open : WE_ADS3.jpg (x60)
Apr 09 05:26:49 Can't open : WE_ADS3.jpg (x46)
Apr 09 05:26:49 Can't open : WE_ADS1.jpg (x2)
Apr 09 05:26:50 Can't open : WE_ADS1.jpg (x8)
Apr 09 05:26:51 Can't open : WE_ADS1.jpg (x8)
Apr 09 05:26:52 Next LOD
Apr 09 05:26:52 Can't open : WE_ADS1.jpg
Apr 09 05:26:53 Can't open : WE_ADS1.jpg (x9)
Apr 09 05:26:54 Can't open : WE_ADS1.jpg (x10)
Apr 09 05:26:55 Can't open : WE_ADS1.jpg (x9)
Apr 09 05:26:55 Can't open : WE_ADS3.jpg (x2)
Apr 09 05:26:56 Can't open : WE_ADS3.jpg (x62)
Apr 09 05:26:57 Can't open : WE_ADS3.jpg (x64)
Apr 09 05:26:58 Can't open : WE_ADS3.jpg (x63)
Apr 09 05:26:59 Can't open : WE_ADS3.jpg (x54)
Apr 09 05:26:59 Can't open : WE_ADS1.jpg
Apr 09 05:27:00 Can't open : WE_ADS1.jpg (x9)
Apr 09 05:27:01 Can't open : WE_ADS1.jpg (x9)
Apr 09 05:27:02 Can't open : WE_ADS1.jpg (x9)
Apr 09 05:27:03 Can't open : WE_ADS1.jpg (x9)
Apr 09 05:27:04 Can't open : WE_ADS1.jpg (x9)
Apr 09 05:27:05 Can't open : WE_ADS1.jpg (x9)
Apr 09 05:27:06 Can't open : WE_ADS1.jpg (x4)
Apr 09 05:27:06 Next LOD (x2)
Apr 09 05:27:06 Meshes : 52
Apr 09 05:27:22 Could not compile pixel shader (Car1) D3DXERR_INVALIDDATA
Apr 09 05:27:22 :41:26: error: syntax error, unexpected KW_REGISTER, expecting VAR_IDENTIFIER or TYPE_IDENTIFIER or NEW_IDENTIFIER
Apr 09 05:27:22 (x2)
Apr 09 05:27:22 Could not compile vertex shader (Car1) D3DXERR_INVALIDDATA
Apr 09 05:27:22 :44:34: error: syntax error, unexpected KW_REGISTER, expecting VAR_IDENTIFIER or TYPE_IDENTIFIER or NEW_IDENTIFIER
Apr 09 05:27:22 > Welcome to our server, enjoy your stay!
Apr 09 05:27:32 Next LOD (x3)
Apr 09 05:27:32 Meshes : 55
Apr 09 05:28:35 shutting down
Apr 09 05:28:35 free objects
Apr 09 05:28:35 free languages
Apr 09 05:28:35 free controllers
Apr 09 05:28:35 clear light map
Apr 09 05:28:35 close sound
Apr 09 05:28:35 close rift
Apr 09 05:28:35 free humans
Apr 09 05:28:35 free font
Apr 09 05:28:35 free helmet
Apr 09 05:28:35 kill graphics
Apr 09 05:28:36 save calibrations
Apr 09 05:28:36 save controls
Apr 09 05:28:36 save views
Apr 09 05:28:36 save config
Apr 09 05:28:36 free mouse
Apr 09 05:28:36 EXIT
Could not create texture WSTfloodL1
Can't open : WSTfloodL1
Could not create texture ambulance
Can't open ambulance
Could not create texture FFoffwall
Can't open : FFoffwall1
...
Can't open : WE_ADS1.jpg (A lot)
...
Can't open : WE_ADS2.jpg (A lot)
...
Can't open : WE_ADS3.jpg (A lot)
...