I just thought this was sort of interesting... Here I am trying to read a file and output to the terminal every line with the line number before...
This is a comparison between PHP and BASH to do this task
PHP:
#!/usr/bin/php -q
<?php
foreach ( file( $filename) as $line_num => $line ) {
echo ( "$line_num:$line" );
}
?>
BASH:
#!/bin/bash
i=1
while [ $i -le `wc -l $filename | gawk '{print $1}'` ] ; do
line=`head -$i $filename | tail -1`
echo $i:$line
i=`expr $i + 1`
done
There is also a difference in execution speed.
The PHP version takes more time to load then bash, but executes MUCH faster.