Skip to content

Instantly share code, notes, and snippets.

@svieira
Last active August 29, 2015 14:01
Show Gist options
  • Save svieira/84026e5b9268f166df11 to your computer and use it in GitHub Desktop.
Save svieira/84026e5b9268f166df11 to your computer and use it in GitHub Desktop.
User-agent from the command line
{
"name": "parse-user-agent",
"version": "0.0.1",
"private": true,
dependencies: {
"platform": "~1.1.0",
"split": "~0.3.0"
}
}
#! /usr/bin/env node
var platform = require('platform');
process.stdin.pipe(require('split')()).on('data', function(line) {
var browserInfo = platform.parse(line);
if (browserInfo.version) {
console.log(browserInfo.name, "-", browserInfo.version.split(".")[0]);
}
});
awk -F\" '{print $6}' your_combined_log |
./parse.js |
# Sort and print the user agents in descending order
sort |
uniq -c |
sort -g -k 1 -r |
less
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment