iPhone and Linux

Friday, March 19, 2010

Nexus One

I did it. I bought a Nexus One. I've only had a few minutes to play with it so far and my initial impression of the interface is that it makes the iPhone feel clunky and boring. I don't know if it will be an iPhone killer, but there's a lot to like about this phone.

I plan to continue this blog because I enjoy hacking around on the iPhone. I'll probably start a different blog for the N1.

Taken with my iPhone. I'm going to go out on a limb and say the N1's 5MP camera with flash could probably have done better than my old 3G.

Thursday, March 18, 2010

Script for looking up language codes

Shhh, don't tell anyone but I've made a secret post. It's a simple script to look up language codes, but it's 1100 lines long. The script is one simple grep command, the other 1100 lines are just languages and codes.

I made the post date Jan 1 2009 so it would go straight to the archive and not take up the front page. It can be found here.

It may be useful to anyone running my iPhone language deleting script who runs across an unknown language code.

Wednesday, March 3, 2010


Another simple script to replace the missing whereis command on the iPhone.
#! /bin/sh
ls /usr/bin/$1 2>/dev/null
then echo >/dev/null
ls /usr/local/bin/$1 2>/dev/null
then echo >/dev/null
ls /usr/sbin/$1 2>/dev/null
then echo >/dev/null
ls /sbin/$1 2>/dev/null
then echo >/dev/null
ls /bin/$1 2>/dev/null
then echo >/dev/null
echo "$1 not found in /bin /sbin /usr/bin /usr/sbin /usr/local/bin"
Too bad an if statement needs a then statement to go with it. Since ls has it's own output, there's no reason to duplicate it so it's easier to use the ls output and do an empty then command. The result works, but it just looks dumb. Here's a shorter version. It will list all the files. If any are not found, the error goes to /dev/null.
#! /bin/sh
ls /usr/bin/$1 /usr/local/bin/$1 /usr/sbin/$1 /sbin/$1 /bin/$1 2>/dev/null
But that won't give you a "not found" message. So let's take that and put it in a variable. If the variable is not empty, it will echo the variable, which is the non-error output from the ls command. If it ends up empty, the -n test will fail so the && command is skipped and the || command executes.
#! /bin/sh
test=$(ls /usr/bin/$1 /usr/local/bin/$1 /usr/sbin/$1 /sbin/$1 /bin/$1 2>/dev/null)
[ -n "$test" ] && echo $test || echo "$1 not found in /bin /sbin /usr/bin /usr/sbin /usr/local/bin"

Blog Archive