Will's Really Useful Engines

What is this page about, anyway? It doesn't say anything about my family, my other interests outside work, etc. If you already know about me and my interests, fine. If you don't, fine. Which begs the question, what is this page doing here? Well, I've been asked a couple of times to post various code I've written, so here is a collection of code: shell scripts, awk scripts, Tcl scripts, and C programs. Some of them really are useful and some of them probably aren't. A couple of them aren't even my own work, but are so simple, cool, and useful, that I've included them below (their authors are identified in the script description).

To fetch any of them, go to its long description and shift-click on the link. Simple stuff like scripts that are a single text file will arrive unpackaged. Anything that consists of more than one file is packaged as a gzip'd tar file (.tar.gz).

(Disclaimer: There may be bugs in any of these programs. Use at your own risk.)

And without further ado, here are the programs:


cleanuppath
tidies up your PATH envvar (gets rid of non-existent and duplicate directories).
clock
is a little command-line clock with precise 0.1-sec updates.
compdir
recursively compare two directories.
csh2shenv
converts a csh environment into a form that can be sourced by sh.
dirfits
makes a directory listing of FITS files.
dtags
creates a tags file for #define's.
duptape
duplicates data tapes, preserving record lengths and filemarks.
extract,replace
Extract copies chunks of characters from a file to stdout; replace performs the inverse operation.
filestrings
searches for path-like strings in binary files.
follow
follows symbolic links, and prints the pointed-at names.
ftags
creates a tags file for Fortran files.
hdr
copies header line(s) to stdout before applying a filter to stdin.
hilight
is a filter to highlight selected text from stdin.
hold
lets you use the same file for both input and output in a command pipeline.
lines
is a convenience script to print lines from a file.
lineup
aligns input fields into nice readable aligned columns.
maillog
selects and formats entries from a sendmail log, by any combination of log fields.
mklinks
creates a `shadow' collection of symlinks pointing at real files.
nmsearch
provides a grep-like interface to searching object libraries.
pathrelay
copies (or forwards) data between all paths and sockets on its command line.
pdiff
is diff with side-by-side output.
printers
reads /etc/printcap or /etc/printers.conf and prints descriptions of printers.
rpn
a reverse-polish-notation calculator.
ruler
is really trivial: prints a ``ruler'' on the screen.
sets
implements basic set operators on its command-line arguments.
shfuncs
a small collections of Bourne-shell functions, especially useful in dot-files.
sourcery
is a template for writing environment-setting scripts that can be sourced from either csh or sh.
sps
A tcl wrapper for ps(1), adding several useful features.
strtox.c
contains greatly enhanced versions of strtol, strtoul, and strtod.
super
provides restricted access to setuid-root commands, and a safe execution environment for scripts.
tcltags
creates a tags file for Tcl files.
timetransfer
transfers the mtime (plus optional offset) from one file to another.
titlebar
lets you write a string into a window's titlebar.
treedu
displays the output of du(1) in a tree structure.
trim
removes leading and/or trailing whitespace from its input.
Which
is an enhanced which command.


cleanuppath
This simple script checks if each entry in $PATH is a real directory or not. It discards all the non-directory components and all the duplicates. It's useful in .cshrc or .bashrc files, because you can go ahead and casually compose an over-generous PATH and then use
    PATH=`cleanuppath`
	
to get rid of the cruft.

Source Language:
Tcl (18 lines)

Documentation:
none (just read the little script).

To build:
adjust the tclsh path at the top of the script.

clock
This little program continuously prints the time in the format
hh:mm:ss.ss
Its value is that it prints time with finer granularity than the 1-second clock normally available, and its printing is synchronized to the correct time -- that is, when it prints 12:34:56.7, the time really is within a few ms of 12:34:56.7 (according to your system clock!), and won't be (say) 12:34:56.66 or 12:34:56.73.

Source Language:
C (31 lines)

Documentation:
none

To build:
gcc -O -o clock clock.c

compdir (compdir.tar.gz) | man page
Compdir recursively compares the files in two directories, and prints the names of the files that differ:
compdir dir1 dir2
Unlike diff -r, compdir only prints the names of the differing files (not the contents), and it has command-line options to easily exclude unwanted files. For example, to exclude all .o, .a, and .sl files from comparison of directories dir1 and dir2, you can do:
compdir -X "*.[oa]" "*.sl" dir1 dir2

Source Language:
C

Documentation:
man page

To build:
Edit the Makefile, then make; make install.

csh2shenv
Csh2shenv is a tiny csh script that prints its environment in a format that can be sourced in by a Bourne-shell script. If you use tcsh or similar, this is a handy tool for importing your tcsh environment into your X session startup. For example, if your X session is started from $HOME/.xsession, you could do this near the top of the .xsession file:
	csh $HOME/bin/csh2shenv > $HOME/.shenv-tmp
	. $HOME/.shenv-tmp
	

Source Language:
C-shell (8 lines, most of which is comment)

Documentation:
in the script

To build:
no changes required

dirfits
This script makes a directory-style listing of the FITS files and directories named on the command line. (Directories are recursively processed to summarize the FITS files in each directory.) By default, the date/time, elapsed time, and object name are printed for each FITS file, but any fields can be selected. Example:
	    % dirfits r22*.fits
	    r220.fits    1999-04-12T03:20:43.0       bias
	    r222.fits    1999-04-12T03:22:27.0       bias
	    r224.fits    1999-04-12T03:24:48.0       bias
	    r226.fits    1999-04-12T03:26:54.0       bias
	    r228.fits    1999-04-12T03:32:57.0       GD71
	    r229.fits    1999-04-12T04:11:56.0       object direct for 99by
	

Source Language:
Tcl (243 lines)

Documentation:
dirfits -h

To build:
adjust the tclsh path at the top of the script.

dtags
dtags generates a tags file for #define's. The dtags output can optionally be merged into a standard tags file. The value of this is that you can jump (when editing source code) to a macro definition as easily as you can jump to a function definition.

Source Language:
Shell script (56 lines)

Documentation:
dtags -h

To build:
no changes required

duptape and recordio | man page
This pair of programs let you duplicate data tapes. Duptape copies one or more files from one tape to another, preserving record lengths. The tape drives can reside on different machines. Alternatively, you can copy from tape to disk and later back to another tape.

Duptape is a script that uses recordio to do the actual copying. When reading a tape, recordio creates a single stream of data that represents the tape. The stream includes both the actual data bytes plus metadata that specifies each record length and the filemarks. When writing to a tape, recordio reads one of these date-plus-metadata streams, and uses the embedded record and filemark information to create a precise copy of the original.

Source Language:
C and sh

Documentation:
man page and
README

To build:
Unpack the archive, edit the make file, and then make; make install.

extract, replace | man page
Extract is used to copy out parts of a file and write it to the standard output. Replace performs the inverse operation: it overwrites parts of a file with replacement data read from the standard input.

These tools can occasionally be helpful when operating on rigorously fixed-format files. (Fancier binary-file editors can do this stuff better, but these are extremely fast when pulling sparse but regular data from large files.)

Source Language:
C

Documentation:
man pages

To build:
Unpack the archive, edit the make file, and then make; make install.

filestrings
All too often I find it necessary to use the strings command to look inside a binary file and try to discover its associated configuration and other files. Filestrings is a helpful ally that greatly simplifies this otherwise tedious search.

Filestrings is a script that applies the strings command to a file, and then keeps only the results that

By default, the resulting strings are passed through sort -u. The result can be readily inspected by eye, whereas the result of simply applying strings is typically a mess of hundreds of lines.

For example, here is the result of applying filestrings to /sbin/portmap on a Linux system:

	$ filestrings /sbin/portmap
	/bin/sh
	/dev/null
	/etc/hosts.allow
	/etc/hosts.deny
	/lib/ld-linux.so.2
	
It is very simple to see that the portmapper is probably processing /etc/hosts.allow and /etc/hosts.deny. By comparison, the output of plain strings is about 300 lines long, and is correspondingly difficult to browse through.

Filestrings is complementary to programs like truss (on Solaris) or strace (on Linux), which print the system calls that are made while a program runs. Inspecting the open() calls will show which files are opened; however, it's not always opportune or safe to run arbitrary programs in such a test configuration, and furthermore different run-time options can change the particular files opened, as can environment variables or some disk data. By contrast, filestrings cannot say exactly which files will be opened, but it does show all the built-in paths.

Source Language:
sh (35 lines)

Documentation:
filestrings -h

To build:
no changes required.

follow (v1.1.0)
If you have ever been trapped in a maze of twisty symlinks, all alike, then you may find follow useful. It helps tease out the actual directory and pathnames that can be hidden in a nest of symlinks.

Follow takes each command-line argument to be a pathname. If the path is not a symbolic link, it simply prints the path. Otherwise, it follows the (possible chain of) symlink pointers from start to end, printing each link along the way. For each link printed, it also prints a non-symlink path to the file.

Follow can also follow every path component that makes up a pathname, which is helpful when one or more directories along the way are themselves symbolic links. As a convenience, it can also do ls -l on each path printed.

Source Language:
C (349 lines)

Documentation:
follow -h

To build:
Edit the Makefile, then make; make install.

ftags
Ftags generates a tags file for Fortran files. Restrictions: the Fortran word "function" or "subroutine" must be space- or tab-delimited on the left, and appear on the same line as the routine name.

Source Language:
Shell script (65 lines)

Documentation:
ftags -h

To build:
no changes required

hdr
This program helps you keep the header lines from data that you are otherwise filtering. It's easiest to show by example. Suppose you want to grep for a line in ps(1) output. You can do this:
% ps -ef | grep whatever
will 20369 6535 0 13:20 pts/9 00:00:00 grep whatever
but the grep command has thrown out the column titles along with the unwanted data.

The hdr command will keep the first (or more) line, and then apply the grep command to the rest of the input:

% ps -ef | hdr grep whatever
UID PID PPID C STIME TTY TIME CMD
will 20372 6535 0 13:22 pts/9 00:00:00 grep whatever

The general use is

hdr [-Nlines] command...
which will keep Nlines of header before the command is exec'd to process the rest of the input.

Source Language:
C (78 lines)

Documentation:
hdr -h

To build:
Edit the Makefile, then make; make install.

hilight
is a filter to highlight (with boldface, reverse-video, or underlining) selected text from stdin. For instance, feeding this paragraph to the command ``hilight is'' produces:
hilight is a filter to highlight (with boldface, reverse-video, or underlining) selected text from stdin. For instance, feeding this paragraph to the command hilight is produces:

The default hilighting is the terminal's standout escape sequence. There are options to explicitly select boldface, reverse-video, or underlining. Pagers such as less may not pass the highlight escape sequences through to the terminal (for example, the ASCII ESC character may be printed as \E), so there are also options to generate output in a format that less will correctly display.

Source Language:
Shell + sed + awk script (185 lines)

Documentation:
hilight -h

To build:
no changes required

hold
is a little script that lets you use the same file for both input and output in a command pipeline. It takes one argument, file; copies stdin to a temporary file until EOF is encountered; and then copies the temporary file into file.

For example, to overwrite textfile with only its lines containing woogums, you can write

grep woogums textfile | hold textfile
Hold is a variant of the overwrite script from Brian W. Kernighan and Rob Pike's The Unix Programming Environment (Prentice Hall, Inc., 1984; ISBN 0-13-937681-X). Although published in 1984, it remains the best book ever written on the general topic of programming under Unix.

Source Language:
Shell script (13 lines)

Documentation:
none; see the code

To build:
no changes required

lines
Lines is a trivial script to print lines from a file (stdin is used if there is no file argument). It's here just because it's more convenient to bang out
lines 1-30,67,158-200 myfile
than to put
sed -n -e 1,30p -e 67p -e 158,200p myfile
Lines has one option: -n causes it to prefix each line with its line number from the original file.

Source Language:
sh and awk (50 lines).

Documentation:
lines -h

To build:
no changes required.

lineup
Lineup aligns the columns from the named file(s) (stdin is used if there are no file arguments). It comes with lots of options to control the alignment details.

Lineup is useful for tidying up the output from a script into an easily readable format.

Source Language:
sh and awk (263 lines).

Documentation:
lineup -h

To build:
no changes required.

maillog (v 1.9.1) | man page
Maillog is a powerful tool for selecting and formatting entries from a sendmail or postfix log. When a message is selected, it collects all the mailer entries related to that message's queue id and formats them in a more readable fashion. By default, the log fields that are printed are: date, from, to, ctladdr, stat, and notes.

Maillog's capabilities are perhaps best show by example:

  1. Select the mail that is to jeepers and from creepers:
    maillog to#jeepers from#creepers syslog
  2. Select the mail that is to user june or user july, and is from user august:
    maillog { to#june or to#july } and from#august syslog
  3. Select the mail that is to jen, and arrived on Apr 19, between 3:17:00 and 3:17:59, inclusive:
    maillog to#jen 'date==Apr 19 3:17' syslog
  4. Select the mail that is to lil and from abner and has a date of today, any time on Mar 20, or after Apr 3, 3:17am:
    maillog to#lil from#abner \
    { 'date==today' or 'date==Mar 20' or 'date>Apr 3 3:17' } syslog
  5. Here is a complete sample with a brief description of the output. The command requests messages from user smith, sent on June 5, before 8:12:
    % maillog from#smith 'date >= jun 5' \
    'date < jun 5 08:12' syslog
                  Message : IAA07301
                     1.506  sunup   date    Jun 5 08:10:10
                     1.506  sunup   from    smith
                     1.512  sunup   date    Jun 5 08:10:15
                     1.512  sunup   to      svasq@sci.gmt.carney.nowhere
                     1.512  sunup   ctladdr smith (87/200)
                     1.512  sunup   stat    Sent (IAA01006 Message accepted for delivery)
    	
                  Message   : IAA01006
                     1.511  helipad date    Jun 5 08:05:56
                     1.511  helipad from    
                     1.513  helipad date    Jul 5 08:06:00
                     1.513  helipad to      
                     1.513  helipad ctladdr  (87/200)
                     1.513  helipad stat    User unknown
                     1.514  helipad date    Jul 5 08:06:01
                     1.514  helipad notes   IAA01014: DSN: User unknown
    	
    Here, host sunup accepted a message from user smith (line 506 in the syslog file), and used host helipad as a relay (line 512; the relay field wasn't printed because this is not a verbose listing), and the stat field shows that helipad's message queue id for the message is IAA01006. At line 511, host helipad accepted the message. (Clearly, helipad's and sunup's clocks are badly skewed, since helipad says that it accepted the message about 4 minutes before sunup says that it sent the message). Four seconds after accepting the message, helipad recorded that the message was undeliverable because "User unknown" (line 513).

Source Language:
Tcl wrapper plus C lexer.

Documentation:
man page

To build:
Edit the Makefile, then make; make install.

mklinks
If you have ever had to manage a large /usr/local or /opt or similar tree, you know the job can be quite a mess. One of the biggest problems is knowing which file belongs to which package -- it's pretty obvious that gs is part of the Ghostscript package, but it's a lot less obvious that wftopa also belongs there. A good approach to alleviating this problem is to install each package's files into its own install area (e.g. /opt/gs/bin, /opt/gs/lib, /opt/gs/man, ...), and then to make symbolic links from the usual area (/opt/bin, /opt/lib, /opt/man, ...) to the package area. That way, all files in /opt are easily identified with their original package (because the output of ls -l /opt will show each link pointing into its package directory), yet at the same time, all the binaries are easily available to users, who don't have to add every package name to their PATH variables.

Mklinks is a tool for creating the flocks of symlinks that point back to the real files. It is longer than some other scripts that do a similar job, but that is because it does much more robust error-checking and plausibility-checking.

Source Language:
sh (170 lines)

Documentation:
mklinks -h

To build:
no changes required.

nmsearch
This script gives a nice grep-ish interface for searching libraries.

Nm is a command to display the symbol table of object files or libraries. However, its output is quite verbose, and it doesn't supply a means of listing just the entries that refer to a particular symbol. Nmsearch combines nm with grep to limit the output to stuff matching a particular grep pattern.

This is quite helpful when your linker has complained that some symbol can't be found, and you need to figure out what library is missing from your link line. For example, here is a command line to find the library that defines BigPush:

	$ nmsearch BigPush /usr/lib/*.a /usr/lib/*.sl
	/usr/lib/libcompface.a
	00000040 T BigPush
	         U BigPush
	

Source Language:
sh (30 lines)

Documentation:
nmsearch -h ...which is nothing more than:
Use: nmsearch [grepoptions] pat lib-file...

To build:
no changes required.

pathrelay (pathrelay.tar.gz) | man page
Pathrelay relays (copies, forwards) data among all the paths and/or sockets named on its command line. Example: give network access to a serial device by relaying between the serial port and socket 1234, limiting the network connections to hosts matching glob pattern 192.168.*.*:
	pathrelay -mode "19200,odd,8,1" /dev/ttyS0 \
		-allow "192.168.*.*" 1234
	

Source Language:
Tcl (293 lines)

Documentation:
man page

To build:
Edit the script and adjust the tclsh at the top.

pdiff
(parallel diff) runs diff in the usual manner -- with most of the usual diff options -- and then filters the output to produce a side-by-side listing of the differences. (If you want a full graphical user interface, then I highly recommend tkdiff. Pdiff has fewer features than tkdiff, but displays the output on your plain terminal.)

Pdiff has a lot of options so that you can arrange the output to be as visually useful as possible. See pdiff -h for all the options.

Source Language:
Tcl (1100 lines)

Documentation:
pdiff -h

To build:
no action required

printers
This script reads /etc/printcap or /etc/printers.conf (whichever is more recent), and prints the description of each printer or alias named on the command line. If no printers are listed, then the names of all known printers are summarized, with the default printer being flagged with ``***''. Each command-line argument is treated as a glob pattern, so it's easy to select multiple printers.

The special printer names local or attached mean to print the detailed description of all locally-attached printers, ie printers for which there is no rm field, or for which there is a bsdaddr field that matches our host.

The script also contains an English description of most fields in a printcap file, so it's easy to understand the entry. For example, the following entry:

	hp04|color2|inkcolor|hpdj1600|HP DeskJet 1600CM Color Printer:\
        :lp=/dev/hp04:sd=/var/spool/printers/hp04:\
        :lf=/var/adm/hp04-errs:af=/var/adm/hp04-acct:\
        :mx#0:if=/opt/transcript/lib/psif:gf=/opt/transcript/lib/psgf:\
        :nf=/opt/transcript/lib/psnf:tf=/opt/transcript/lib/pstf:\
        :rf=/opt/transcript/lib/psrf:vf=/opt/transcript/lib/psvf:\
        :cf=/opt/transcript/lib/pscf:df=/opt/transcript/lib/psdf:
would be displayed as:
hp04 (color2, inkcolor, hpdj1600): 
        HP DeskJet 1600CM Color Printer

  lp=/dev/hp04                   # Device name to open for output.
  sd=/var/spool/printers/hp04    # Spool directory.
  lf=/var/adm/hp04-errs          # Error-logging filename.
  af=/var/adm/hp04-acct          # Name of accounting file
  mx#0                           # Max file size, in BUFSIZ blks. 0=inf.
  if=/opt/transcript/lib/psif    # Name of text filter that does accounting.
  gf=/opt/transcript/lib/psgf    # Graph data filter (plot format).
  nf=/opt/transcript/lib/psnf    # Ditroff data filter.
  tf=/opt/transcript/lib/pstf    # Troff data filter.
  rf=/opt/transcript/lib/psrf    # Filter for FORTRAN style text files.
  vf=/opt/transcript/lib/psvf    # Raster image filter.
  cf=/opt/transcript/lib/pscf    # The cifplot data filter.
  df=/opt/transcript/lib/psdf    # Tex data filter (DVI format).

Source Language:
Tcl (236 lines)

Documentation:
printers -h

To build:
Edit the script and adjust the tclsh call at line 3, and change the domain field in the CONFIGURATION section (line 8 or so).

rpn (v 1.2.1) | man page
This program is a reverse-polish-notation calculator. If given an expression on the command line, it evaluates the expression, prints the result, and exits. Otherwise, it enters an interactive mode.

Rpn's use will be familiar to users of HP's RPN calculators; if you like those calculators, you may well like rpn; otherwise, don't bother looking at it. I find it quicker to use than the calculators normally available on Unixen.

Rpn has a rich set of operators, including both bitwise and the usual mathematical operators (including most of the standard C math library). You can also define variables and macros, and execute procedures that have been stored in a file.

Source Language:
C.

Documentation:
man page

To build:
Edit the Makefile, then make; make install.

ruler
This is a pretty trivial little script, but sometimes you need something like it: it just prints something like
....+....1....+....2....+....3..
all the way across the width of the screen. The -o option tells it to overwrite the command line, which is handy when you want a ruler to appear immediately underneath some text that was just printed.

I find it useful to define a vi macro to invoke the ruler command. My .exrc file contains the following line:

:map ^R :r! ruler ^M
where ^R is a literal control-R, and ^M is a literal Return (you can enter these in vi by using cntl-v cntl-r and cntl-v cntl-m, respectively). Then, typing ^R creates a ruler just below the cursor. Of course, you could skip the ruler script and instead put a line similar to the following in your .exrc file:
:map ^R o....+....1....+....2....+....3... (etc) ESC
(here, ESC is a literal escape), but in that case you get a fixed-length ruler instead of one that will matches the width of the screen. (The shell script itself spends most of its time figuring out the screen width. This is tedious because stty comes in two very different flavors which are very different in the way they can be embedded in command substitution, and because there are at least three major ways of formatting the stty output.)

Source Language:
Shell script (60 lines: 56 lines to determine the tty width; 4 lines for the ruler!)

Documentation:
ruler -h

To build:
no changes needed.

sets
implements basic set operators, which makes it easy to select subsets of files, like this:
% grep somestring `sets *.c -not xxx.c`
The general format is
sets e1... op1 e2... op2 e3...
where op's are operators and e's are any elements not in the operator list. The output is the elements formed by evaluating the operators left-to-right. The valid operators are:
-i
(intersection)
-u
(union)
-not
(remove words from left wordgroup if they are in right wordgroup)

Source Language:
TclX (105 lines) (note that this is extended tcl, not vanilla Tcl).

Documentation:
just type sets (without any arguments)

To build:

shfuncs
This file holds a small collections of general-purpose Bourne-shell functions that are often useful in dot-files.

The functions are:

arg
arg N words returns the N'th word. For example,
arg 3 a b c d e
returns "c".

findcommand
findcommand cmd looks for cmd in your PATH. It returns the path if cmd exists, else an empty string. Example:
# Start vnc server if it is avail.
test `findcommand vncserver` != "" && vncserver ...
testbool
testbool value sets the status to 0 if the value is true, else 1. Useful for testing the value of prompt strings:
echo -n "Proceed (y/n)? " ; read ans
if [ testbool "$ans" ] ; then
...
fi
colonjoin
colonjoin words joins all the words arguments together with colons. This makes it easy to convert a list of space-separated paths (which are therefore easy to read and edit) to a proper colon-separated path:
PATH="a b c ..."
PATH="$PATH d e f ..."
...
PATH=`colonjoin $PATH`

Source Language:
sh (64 lines)

Documentation:
none; see the code

To build:
no action required

sourcery
This is a template for writing code that can be sourced from either csh (source file) or sh (file).

You just fill in a section with whatever Bourne-shell code you desire, and the template code handles the magic to let you source it from either kind of shell.

As a result, you can write a single Bourne-shell file to provide a common environment for a suite of shell scripts that may be written in both csh and sh. (Perhaps you are thinking that while this is a pretty cool trick, it is even more amazing that anyone would want to write scripts in csh, but let's just call that one of the mysteries of life.)

Source Language:
sh or csh (56 lines)

Documentation:
Via comments in the template.

To build:
Fill in the blanks, and give it a new name.

sps
The name sps stands for `sorted ps', and it has four main functions:

Source Language:
Tcl (485 lines)

Documentation:
sps -h

To build:

strtox.c
This C source file contains greatly enhanced versions of strtol(), strtoul(), and strtod(), called EXstrtol(), EXstrtoul(), and EXstrtod(), respectively.

Warning: the price of these enhancements is that no range-checking is done!

The extensions include:

Base 2:
(EXstrtol and EXstrtoul only): if compiled with -DALLOW_0B, the prefix 0b or 0B means a base-2 number (e.g. 0b1101 means 13).

Many other bases:
(EXstrtol and EXstrtoul only): the prefix ``bX%'', where X is from [2-9a-zA-Z], gives the base. For example, b9%17 means 17 base 9 = 16.

Scaling with [Xx]nnn:
the suffix [Xx]nnn means to multiply by nnn (e.g. 100x2 means 200).

Scaling with [Ee]nnn:
the suffix [Ee]nnn means to multiply by 10^nnn (e.g. 1.23E2 means 123).

Scaling with [KkMmGg]:
the suffix [KkMmGg] means to multiply by 2^10 (if K), or 2^20 (if M), or 2^30 (if G). (e.g. 1K means 1024).

Simple arithmetic:
if you set the extern variable strtox_allow_arith is set to a non-zero value, then the suffix [-+/*%]nnn means to carry out the corresponding arithmetic operation (e.g. 20+4 means 24).

Powers:
the suffix ^mmm means to raise the value left of ^mmm to the power mmm (e.g. 3^4 means 81).

Any number of extensions can be applied; they are all evaluated left-to-right. For example, 20e3+4*6 means 120024.

Source Language:
C

Documentation:
See the comments in the source

To build:
Compile in the usual way.

Super (super-3.30.0-tar.gz) | README | Changes | User's man page | Configuration man page
Super is a setuid-root program that offers

Sample uses:

Source Language:
C

Documentation:
Thorough README, INSTALL, and man pages.

To build:
Unpack the archive, then follow the INSTALL guide: ./configure; make; make install.

tcltags
This script creates a tags file for Tcl scripts. The good news: it's extremely simple (just two awk commands plus a sort command) creates the tags file. The bad news: it's so simple that it's incomplete: it doesn't know anything about Tcl syntax or namespaces, so all it does is to look for lines whose first word is proc, and uses the second word as the procedure name. (Works for me :-).

Source Language:
shell script

Documentation:
none -- just inspect the script!

To build:
no changes required.

timetransfer | man page
timetransfer copies the last-modified time from one file to another. This is helpful if a timestamp needs to be transferred to a file. If an argument like +xxx or -xxx is present, then xxx seconds (a float value) is correspondly added to or subtracted from the modification time.

Example 1:

timetransfer file1 file2
transfers the mtime from file1 to file2.

Example 2:

timetransfer +86400 file1 file1
increases the mtime of file1 by 1 day (86400 seconds).

Source Language:
C

Documentation:
man page

To build:
Edit the Makefile, then make; make install.

titlebar | man page
Titlebar is a script for placing a string into the titlebar of a window (default the current window). Its use is simply
titlebar [-tty] text
e.g.
titlebar this is a title

Source Language:
shell script

Documentation:
man page

To build:
Edit the Makefile, then make install.

treedu
is a script to execute du(1), and then display the output with indentation to show the directory depth. The -maxdepth option limits the subdirectory depth displayed to maxdepth subdirectories deep, so that you can get an overview of disk use without having to list the details of every directory tree.

Source Language:
shell script (70 lines)

Documentation:
treedu -h

To build:
no changes needed.

trim
deletes leading and/or trailing whitespace from each line of each file named on the command line (default stdin). The result is put onto stdout. Trim has options to trim only the left side or right side; to trim characters other than whitespace; and to truncate the output to a certain number of characters or screen widths after trimming is done.

Source Language:
Tcl (83 lines)

Documentation:
trim -h

To build:
Edit the script and adjust the PATH specification at line 3.

Which
This is an enhanced variant of the C-shell built-in `which' command. It works under both csh- and sh-type shells. This variant (Which with a capital W) adds two useful features:

Which is a bit dumb about the shell flavor: if your login shell ends with csh, it assumes that you are currently using a C-shell (or variant); otherwise, it assumes that your current shell is Bourne shell (or variant).

Which checks for aliases by executing a copy of your login shell, and checking the aliases that are defined in that shell. It then checks each directory in your current PATH.

Example 1: check which rdist commands are available:

	    % Which rdist
            /opt/bin/rdist
            /usr/local/bin/rdist
            /usr/bin/rdist
	

Example 2: list all commands with dist in the name:

	    % Which "*dist*"
             /opt/bin/rdistd
             /opt/bin/rdist
             /u/will/bin/dupdir.rdist
             /opt/bin/rdistd
             /opt/bin/rdist
             /opt/share/bin/sdist
             /opt/share/etc/distrib
             /opt/share/etc/sdist_ssh
             /opt/share/etc/cron.dist
             /usr/local/bin/rdistd
             /usr/local/bin/rdist
             /usr/sbin/rdistd
             /usr/bin/ppmdist
             /usr/bin/dist
             /usr/bin/rdist
             /usr/bin/rdistd
	

Source Language:
Tcl (63 lines)

Documentation:
none

To build:
Edit the script and adjust the PATH specification at lines 3-4.

will@ucolick.org
Will Deich
UCO/Lick Observatory
University of California
Santa Cruz, CA 95064
Tel: +1 (831) 459-3913
Fax: +1 (831) 459-2298