Craig's Unix Utilities

Here are the Unix utilities that I have hacked together. All of this software is copyright (c) Craig Bruce, free to use, modify, and redistribute.


CRC-32 version 1.04

This program displays the CRC-32 error-checking values for given files. This is useful for quickly checking if you have transferred a file from one place to another correctly or not. The hexadecimal CRC-32 values shown are the same as those used by PKZIP and ZMODEM.
crc32.txt -- The documentation for the program.
crc32.c -- The complete C-language crc32-generator program.


Move-with-Pattern program version 1.01

This program will rename a group of files according to the same pattern. The pattern specifier allows you to insert and cut text from random positions in the original file names to generate the new ones.

mvp.txt -- The documentation for the program.
mvp.c -- The complete C-language mvp program.

An example use of this program was to change all of the documentation files pointed to by this page from a ".doc" extension to a ".txt" extension, to keep browsers from thinking they are Mess-Word files:

mvp *.doc '*.doc+.txt+'


Day-Of-Week program version 2.01

This question seems to keep coming up on various programming newsgroups, so I finally hunkered down and wrote one. In addition to computing the day of week of any given date, the functions of the program can also check that a given date is valid; return the day number since 1582/10/15 of a given date (you can also find the difference between two dates by subtracting); return the year, month, and date given a day number (the inverse of the previous function... so you can perform date arithmetic (what will the date be in 100 days?...)); figure out the day number of a date in a given year; and convert the day number of a given year into year, month, date format. It slices, it dices, look at that tomato!

But don't answer yet, just look what else you get: There is also a driver program that will allow you to input dates and have it tell what day of the week it is: $ dow 1995/08/04
1995/08/04 is a Friday (dayCount=150773) (inv:1995/08/04) (d.o.year=216)

(it also tells you the day number since the epoch, demonstrates that it can inverse this day number, and tells you the day of the current year). There's also a test option:

$ dow -t
testing year 1582...
[...]
testing year 9998...
testing year 9999...
Test completed successfully

This tests that each valid date has a day number that is one greater than the previous valid date, and that the day number to date conversion works correctly for every valid date in the range of 1582/10/15 to 9999/12/31. This should give you more confidence about using it.

dow.c -- The complete C-language Day-of-Week program. Operators are standing by.

(Apologies to "Weird" Al).

BCODE version 2.02

This program is like uuencode/uudecode, except much better. It accepts four different text-encoding formats (including uucode) and provides automatic splitting, reordering, and incremental reassembly of multiple file segments for long files, and provides CRC-32 and size error checking on each encoded segment, for the three new formats: nucode, bcode, and hexcode. Nucode is both upward- and downward-compatible with uucode. See the documentation for more information. The proper names for the encoder and decoder programs are: "bcode" and "unbcode". There's no need for a Makefile here because each of the C source files is a complete program. Just compile and run.

bcode.txt -- The documentation for the encoder and decoder.
bcode.c -- The complete ANSI-C-language encoder program.
unbcode.c -- The complete ANSI-C-language decoder program.

Also available are the MS-DOS executables for bcode and unbcode (in uuencoded form, version 2.00).


Hex-Dump program version 1.00

This program produces a simple hexadecimal dump of a given file. The program is along the same lines as "od" (octal dump). The output has the following format: 00000000: 00 11 22 33, 44 55 66 77, 88 99 aa bb, cc dd ee ff ;0123456789abcdef

hd.c -- The complete C-language Hex-Dump program.


Huffman-Code Generator program 1.00

This program will accept an input file, compute the Huffman codes for it and report the Huffman codes to standard out. This program does not actually compress the input file; it is for informational purposes only. You can also use this program to report the number of occurrences of each byte value inside of a file.

huff.c -- The complete C-language Huffman-generator program.


KAR version 1.00

This program will produce an archive of multiple text files. The useful properties of this program are that the archive format is very simple and can be de-archived by ad-hoc means (although the de-archiver is included) and the archiver format is all text, so you can view the archive file to read its contents if you want; just don't change it.

kar.txt -- The documentation for the program.
kar -- The complete Bourne-shell (sh) archiver program (very simple).
unkar.c -- The complete C-language dearchiver program.


Deaccent version 1.00

This program will "remove" all of the accents from the extended characters in the ISO 8859-1 (Latin-1) character set, character codes 0xA0--0xFF. Each of the extended characters is mapped to a printable 7-bit ASCII character. I picked the single 7-bit character that best represented the extended one, and I used "@" where there was no good one. You can change the mapping by changing the table at the front of the program (it is in the same order as the character-code table above), and you can even make it produce more than one 7-bit character for an extended character, since a _string_ table is used. Use the null string for characters that you want removed.

deaccent.c -- The complete C-language deaccenting program.


Accentuate version 1.00

Okay, this program wasn't written by me; it was written by Keith Pomakis, but I make contributions to it. This program is sort of the compliment of the Deaccentuate program in that it will read in 7-bit ASCII characters and generate the extended ISO-8859-1 characters where you specify. You specify an 8-bit code by putting a backslash before two characters that "compose" to the extended one. For example, "\'e" will produce code 0xE9 (e with an accute accent). The composition character sequences are based on the VT-220 codes and the complete list is in the source code. To get an actual backslash character in your text, use two backslashes in a row.

accentuate.c -- The complete C-language accenting program.


PoliCor version 1.00

This program is a filter to make any text document be Politically Correct. It does this by scanning the document and converting every fifth vowel to the letter "y".

policor.c -- The complete C-language political-correctness program.

[Go to My Homepage]