zuck-mbpl:~ zuck$ php j play some red hot chili peppers
PHP as a shell scripting language. Old habits die hard, huh? zuck-mbpl:~ zuck$ php j play some red hot chili peppers
PHP as a shell scripting language. Old habits die hard, huh?Quick startup, a good amount of CLI-specific APIs, available on many servers already, and no compiler or huge amount of tools needed.
It's a bit verbose for little scripts that should be in something like bash, but it's a great alternative to something like python if you are more familiar with it.
Ruby
IO.foreach('logs1.txt') {|x| puts x if /\b\w{15}\b/.match? x }
Python3
import re
with open('logs1.txt', 'rt') as fh:
for line in fh:
if re.search(r'\b\w{15}\b', line): print(line, end=' ')
Perl
open my $fh, '<', 'logs1.txt';
while (<$fh>) { chomp; say if $_ =~ /\b\w{15}\b/; }
close $fh;
NodeJS
var fs = require('fs'), byline = require('byline');
var stream = byline(fs.createReadStream('logs1.txt', {encoding: 'utf8'}));
stream.on('data', function(line) { if (line.match(/\b\w{15}\b/)) console.log(line); });
PHP
$fh = fopen('logs1.txt', 'r');
while (($line = fgets($fh)) !== false) {
if (preg_match('/\b\w{15}\b/', $line)) echo $line;
}
fclose($fh);