Tuesday, January 12, 2010

 

Command Line Applications

This article assumes some knowledge of the command line. Before we get into the specifics I should say a little about ncurses. Ncurses is a programming library that enables a programmer to write a text interface for programs running under a terminal emulator, e.g. bash. An application using ncurses can resize itself within certain limits set by the programmer. Note that it is possible to ssh into devices with small displays to use a larger external display.

Text based programs come from three main development groups: GNU, Linux and BSD.

Here are some of the things I find useful to do at the command line:

Script to look up a word in the dictionary:
curl dict://dict.org/d:$1

Script to listen to CBC Radio 1:
mplayer http://icy1.abacast.com/cbc-r1toronto-96
(CBC tends to change things around a lot and this script may not work in the future)

Stream classic music from WGBH:
mplayer http://streams.wgbh.org/classical.asx

Check spelling of standard input (gives suggestions)
ispell -a

This is a script I use when I can remember what a file is called, but can't remember which directory it's in:
TEST=$(dirname `locate -n 1 $1`)
eval cd $TEST

I put this in ~/bin as locate.sh but to get the desired result one would use:
. locate.sh SAK.txt
This would put you in the directory where SAK.txt was located.

The two calendar programs cal and gcal (cal is from the Linux world, and gcal is GNU's version).

Ncurses based IRC program:
irssi

Ncurses based spreadsheet program:
sc (7.16 seems to be the newest version)

Unit conversion:
units
(Example: You have: tempC(0)
You want: tempF
32

Various text based browsers like elinks, lynx and w3m.

I run bc a lot for simple math calculations:
bc -l (run bc with standard math library)

I have accumulated a rather large collection of bash shell scripts over the years but even more useful than the scripts was the text file I keep here: Accumulated Linux Notes. Text based programs are generally smaller in size and execute faster and (this might be the most important concept of all) can be easily ported to other systems.

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]