User Tools

Site Tools


Unix Scripts

I use these scripts every day, they might be useful to others. They might even be useful templates for how to write a decent bash script!! You can download them individually by clicking on the links or you can download this tarball to get them all. Install them somewhere on your path - I use ~/bin. All my scripts honour the -h, –help options.


These are used in my other scripts - a wrapper around getopt(1) to make life much easier for script developers and more predictable for script users. See also

usage for


bh-stdlib - generic functions


xwin-utils generic functions for the X11 scripts

Photo scripts

Generally, these require jhead(1), jpgtrans(1), netpbm-progs (pnmscale(1)), libjpeg (djpeg(1), cjpeg(1))


erect-jpeg - rotate a photo so that it displays correctly by examining the Orientation Exim information in the file. Uses xargs(1) to parallelise operations to as many CPUs as it can find.

usage for label-photos


label-photos - view *.jpg files and prompts for a label for each, putting the label into the Exif comment field. It also recurses through any directories called zoom, applying the same label to photos of the same name.

usage for label-photos


rename-jpeg-by-date - renames jpg files according to the date reported by jhead

usage for rename-jpeg-by-date


resize-jpeg - size a jpeg so that the longest side is the required number of pixels and the other side is scaled.

usage for resize-jpeg


shrink-jpeg - passes photos through djpeg(1) and cjpeg(1) which can result in a size reduction of about 50% without compromising much on quality. The amount of shrinkage depends on the camera, of course.

usage for shrink-jpeg

X scripts

Generally, these require wmctrl(1)


binpack - a python script that optimally packs windows onto the screen - used by the tile script

usage for binpack


fetch-app - bring an application to the front of current monitor no matter which workspace it is on; or starts it up, if necessary

usage for fetch-app


half-screen - changes the window size to a proportion of the monitor size eg a half, a third, a quarter, a sixth, a ninth of the screen

usage for half-screen


move-window - move windows. (requires wmctrl(1))

usage for move-window - jump to the next desktop

usage for


tile - tile all the windows on the desktop (requires wmctrl(1))

usage for tile


xcheck - runs a command (usually X) and shows stdout and stderr in a popup window if there's an error eg xcheck – remote-x11vnc -x xdm

usage for xcheck

general scripts


backup-copy - my backup script - using this, I can keep a backup at a cost of only about 2Mb/day. Uses the hard-linking power of rsync(1)

usage for backup-copy


ff - recursively find files (wrapper for find(1))

usage for ff


fs - recursively search for patterns in files (wrapper for find(1) and grep(1))

usage for fs


fit - fits a bunch of files/directories into CD or DVD sized subdirectories ready for burning

usage for fit


m - pretty display of man pages (needs 'v' and a postscript or pdf viewer) eg m less to get a pretty man page for less(1)

usage for m


mass-mv - renames and or moves files according to a regex; can also clean up filenames removing whitespace and/or weird characters

usage for mass-mv


newest - recursively list files in directories in date order. If called as oldest, reverse the sort direction. If called as biggest or smallest list by file size.

usage for newest


r - run a command with sudo or popup a root xterm

usage for r


refactor - uses find(1) and sed(1) to search and replace

usage for refactor


v - view or execute any type of file going rather beyond the scope of lessopen - in the simple case of a text file this is just shorthand for less(1)

usage for v

unixscripts.txt · Last modified: 2015/12/28 00:11 by admin