Searching apache logs for iPhone User Agents
By Pete Freitag
I was curious if anyone was using an iPhone to read my blog yet, I'm sure before too long we will all be optimizing our sites for 3.5" displays. To find out I did a little grep
on my Apache log file and piped it to wc
to count the number of matches:
grep 'iPhone;' access.log | wc -l
So far 370 hits including images, to take out requests for images I added:
grep 'iPhone;' access.log | fgrep --invert-match images | wc -l
That yields 106 requests, hello iPhone readers...
BTW the user agent for the iPhone looks like this:
Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3
Learn more about grep
There is a lot you can do with the grep linux command. Here, I'm using the --invert-match
flag, which lets you perform a Inverted or Negative grep search. You can also do a case insensitive grep search, or even count files by extension using grep. Grep is one of the most useful linux commands to know!
Searching apache logs for iPhone User Agents was first published on July 19, 2007.
If you like reading about iphone, apple, apache, grep, or unix then you might also like:
Discuss / Follow me on Twitter ↯
Tweet Follow @pfreitagComments
The breakdown within that was:
29.1% Blackberry
28.4% Palm
25.2% WindowsCE
17.3% iPhone
17.3 % is pretty nice for a its first week on the market. I'll measure again in a few months is anyone's interested.
Did you mean to say you searched for browsers containing "iPhone", either way it doesn't look like Google Analytics reports on iPhone's yet.