Android and Linux

Friday, April 16, 2010

Two more missing Linux commands imitated

The "man" and "whatis" commands are two more useful command line utilities that are missing from Android. Here are two more scripts to imitate their function.

These require a network connection because they download information from unixhelp.ed.ac.uk. For this reason, there is no guarantee the information will be accurate for your system. This information is normally installed when the program is installed, but it's not on Android so the best I can do is grab general information off the web.

Please note, you may already have a man command if you have Busybox installed. My Nexus One with Cyanogenmod has man located at /system/xbin/bb/man but it is just a link to Busybox and it didn't work so I just deleted it.

You can use my previous whereis command to see if you have a man command installed:

# whereis man
/system/xbin/bb/man
#

Then run "ls -l /system/xbin/bb/man". If it is a link to busybox, the output will contain this: "/system/xbin/bb/man -> /system/xbin/busybox" and you are safe to delete it. To restore it later, just create a link to busybox named "man".

Anyway, here are the scripts:

man:
#! /system/bin/sh
wget -q -O - "http://unixhelp.ed.ac.uk/CGI/man-cgi?${1}" | grep -A 1000 NAME | sed -e 's/<[^>]*>//g' -e 's/^[ \t]*//'

Copy "man" to your clipboard with this QR code:


whatis:
#! /system/bin/sh
wget -q -O - "http://unixhelp.ed.ac.uk/CGI/man-cgi?${1}" | grep "\- " | head -1 | sed 's/^[ \t]*//'

Copy "whatis" to your clipboard with this QR code:

Followers