Blog posts tagged "unix"
Reading a file backwards in PHP
February 28th, 2008This morning I needed to read from a file line by line from the bottom. In PHP. Perl, of course, has a module to do this. A quick view source decided that I didn’t want to get into file seeks before breakfast. Very happy with my solution:
$file = popen("tac $filename",'r');
while ($line = fgets($file)) {
echo $line;
}
-
April 17, 2006
⇒ man.splitbrain.org - web interface to 45k+ Unix man pages.Clean URLs and design, user contributions. Nicely done, every documentation set should be so lucky. (from the creator of the excellent dokuWiki, uses his MTC comment system)
0.
(Aside community, documentation, linux, reference, unix)
Shell Scripting and Agg Stats
September 21st, 2005Been a while since I dug into my aggregator stats (intrigued by FeedBurner mentioning their tracking 2000 aggregators), and while I’ve got my Perl script, but I was alarmed to realize that I had forgotten the shell for doing the equivalent.
So killing time waiting for J I re-created it. Assumes you’re using Apache’s “full” log format (and that your feed is “index.rdf”)
sudo grep '/index.rdf' access.log | cut --delimiter=\" -f6,1 --output-delimiter="=" |
sed 's/ - - \[[^=]*//' | sort | uniq | cut --delimiter="=" -f2 | sort | uniq -c | sort -n
Returns a count of unique IPs per User-Agent. Tack on a little awk to get aggregate counts.
| awk '{sum += $1; print sum}'
Of course folks like Bloglines, Rojo, Yahoo FeedSeeker, Feedster, and FeedLounge (among others I’m sure) are rolling up the user counts. Of course FeedLounge and FeedSeeker are counted multiple times as they add time sensitive info to their User-Agent (that has got to be against some best practices!), and Bloglines comes from a couple of different IPs.
Interestingly, Google Desktop is showing up as generating not only the highest number of hits, but the highest number of 200s.
-
October 22, 2004
⇒ cal 9 1752.Humans should never have been put in charge of designing calendars
0.
(Aside calendaring, unix) -
September 13, 2004
⇒ UNIX Application or Outlawed Paramilitary/Guerrilla Organization?.McSweeney’s Internet Tendency
0.
(Aside funny, unix) -
May 2, 2004
⇒ Mark has a list of 8 tools I use every day, all day, like oxygen..Well except for Emacs, but I acknowledges that is a personal failing
0.
(Aside unix) -
March 17, 2004
⇒ body.Gnat’s screen tips
0.
(Aside quotable, unix) -
March 16, 2004
⇒ Fink: xscreensaver-gtk2.If you’re running bleeding edge Fink unstable
0.
(Aside fink, osx, unix)



