General-purpose Bash scripts

1998-01:  After switching from MS-DOS to Linux, I stopped writing C-programs to make Dos more Unix-like and began writing shell scripts to make Linux more Dos-like:-)  Actually my only script of that sort, rename, goes well beyond the simple-minded globbing the Dos rename can do.  My first Linux, an early version of Red Hat Linux, had no rename command so I wrote one.  [Linux has had a rename since circa 1999, in the util-linux package, that's almost identical to mine, however I still prefer mine.] 

Here are some general-purpose shell (bash) scripts, written between 1998 and the present:

rename -- systematically rename multiple files according to a specified pattern
chg -- systematically revise files according to a specified pattern (or filter)
chgsed -- my usual way of invoking chg
chgtr -- another way of invoking chg
unchg -- undo chg
arr -- filter to re-arrange columns of a file
bc -- an extended bc for floating-point arithmetic in bash-scripts
bcf -- bc with formatted output
list -- an unambiguous textfile-viewer that displays non-ASCII characters in hexadecimal, using less
scalepix -- image scaling and annotating, for webpage-making, preparing a set of photos for emailing, etc (any image type)
annotatepix -- needed by scalepix, mk-calendar-covers; annotates a photo (only for PPM images)
url-decode -- does URL-decoding (percent-decoding)
fullname -- displays fully-qualified filename
fullnameNOSLASH -- reversibly converts pathname to filename
fullnameRESLASH -- the inverse of fullnameNOSLASH
datecvt -- converts alphabetic to numeric month etc
dateplusdays -- for arithmetic with dates
dateplusmonths -- for arithmetic with dates
datecvt-from-Apache -- date conversion from Apache-Logrecord-format
dateERW -- date command that changes days at 8am rather than midnight
SetIntersection -- set-intersection
SetSubtract -- set-difference
SetUnion -- set-union
nl2sp -- convert from one-per-line to space-separated form
sp2nl -- convert from space-separated to one-per-line form
SubsetOrEqual -- returns TRUE iff FILE1 is leading-subset-of-or-equal-to FILE2
NEWER -- like bash -nt except it correctly handles comparand being a directory
OLDER -- like bash -ot except it correctly handles comparand being a directory
clean -- discards "noise" files like tmp* *~ etc
tolower -- filter to lowercase a string
todosfile -- filter to convert NL-->CR+LF
find-dirs -- uses find to enumerate subdirectories
dif -- an extended variant of Unix-diff, with filtering extensions and terse-output option
difsed -- a frequently used way to invoke dif
ATTRIBS -- displays attributes of an image-file
counted-uniquify -- filter to uniqify-with-count
counted-uniquify-ordered -- filter to uniqify-with-count then order-by-count
cvt-utf8-to-latin1 -- convert textfile from utf8 to latin1 charset
cvt-latin1-to-utf8 -- convert textfile from latin1 to utf8 charset

Incidentally I avoid filenames containing spaces, and some of my scripts may not behave as desired on such names;  however, my rename script does handle them and one of its important uses is to correct them when people send files so named.

Disclaimer: some of these were written before I knew bash well enough to attempt such things:-)


An Easier Way to Install all of the above:

ertools.zip -- zipfile containing all of the above general-purpose scripts, the webmaster-tools, and the other scripts I've published on this site.  (Where scripts includes Bash-scripts, Perl scripts, Python scripts, even "bc" scripts, ie: anything that's handled with a "shebang"-line.)  See README.htm for more info on this collection of tools, and how to install them.  And see Unix-tools for Windows to install for Windows. 



Send your questions, suggestions, corrections to ereimer@shaw.ca.