First up is a utility that I wrote for my bash prompt. It gives the total size of all the files in the current working directory. I wrote it in C because the original example used a bash function that I found quite slow at the time (about 8 years ago). This version has been kept up-to-date over the past 8 years and should now be ready for public consumption.
Here is another handy command line utility. It takes any number of filenames on the command line and it will either rename them all to upper-case or lower-case depending on the name of the executable. The way it is typically built is as lcase with a symbolic link to it called ucase. This quickly solves the problem that typically occurs when you get an older zip archive that has filenames in uppercase.
This one is a bit different. I wrote it because I wanted a way to truncate a file containing a Ext-2 filesystem down to the new size after running resizee2fs. The truncate(2) system call works perfectly for this, but I didn’t see anything that just exposed that functionality via the command line. So, this program was born. There isn’t much in the way of error checking or anything for that matter. It simply takes a filename and the number of blocks you want it to be (in 4KB blocks) and truncates the file. If you need to, you can also specify a different blocksize. Please be careful with this one — it can be dangerous.
Here is a much safer utility — it simply reads stdin, strips out extraneous whitespace, and writes it back to stdout. It’s great to use with cut -f when you have something that uses multiple spaces and/or tabs to split up it’s fields.
This one has, admittedly, become less useful with tools like watch available these days. But, at one time it served a purpose. This utility will monitor the specified file, watching for changes in the file size. Once the file stops changing for 10 seconds (or any other user specified number of seconds), the program will exit. This was useful in scripts where you had to wait for a file to finish being written to before doing something else with it.
Last of the utilities for a while — this one takes a large file and breaks it up into a series of smaller files. Great for fitting large files on multiple CDs (or floppies… if you’re still into that). This code is an example of something that I would most likely write differently if I was writing it today. For example, today I would probably use mmap() instead of reading the chunks into memory and then writing them back out to the new file. Maybe if I’m ever bored or determine that this program is too slow, I’ll re-write. Most likey not, though.