Dennis Lovelady and Friends’ Unix Utilities

Back to Music pages Unix sources RPG API Samples The TAO of Programming Fortune cookies Picture gallery

In the course of doing my job, I end up writing a lot of utility programs. From time to time, I will post code here that others have requested, or that I think others may find useful. Enjoy!

Some utilities provided by others, named in description and/or source.

Words of wisdom:
The TAO of Programming

Thought for the day:

$Fort = new Fortune; echo $Fort->quoteFromDir(Null, True); ?>

Alphabetic index:
adddate: date arithmetic
age: date arithmetic
cronsched: a cron schedule printer
currepoch: print the current time in epoch format (see also
cvtdat: print any given date in any format
epoch2time: convert seconds-since-epoch to a timestamp
lsdate: (by Andy Cranston) displays file modification date/time
rslvlnk: Resolve soft-link name
time2epoch: (by Bob Vance) given mth, day, year, hour, min, sec - provide epoch value
unfind: pipe (by Andy Cranston) to remove pesky entries from stdin

image adddate.c


A utility to return a date in the future or the past. Calculates the date by adding the first parameter to the current date, then prints the result to standard output. The number of days to add may be a negative number, allowing for calculation of dates in the past. The format of the printed date may be specified as the second parameter. If unspecified, the output format will be like: Thu Jan 01 13:36:30 1998. See man strftime for help with formatting.

adddate number_of_days [format_string]

  • The following will print yesterday's date, formatted like "Tue, May 1":
    adddate -1 "%a, %b %d"
image age.c


A utility to return the number of seconds that have elapsed since a certain time.

age Month Day Year Hours Minutes Seconds

image cronsched.c


A cron schedule printer. Reads the specified crontab files, and produces a schedule report. Start time and duration may be specified, as well as the users to be considered. All valid crontab entry formats are accepted by this program, and handled in the same manner as the standard Unix cron processor.

cronsched [-b starttime] [-d duration (days)] [-w print_width] [-s crontab subdirectory] user [user ...]

image currepoch.c A utility to return the current time in epoch format



  • $ currepoch
image cvtdat.c


A utility to return any date in any format. The month, day and year are passed as parameters, along with an optional format string. If unspecified, the output format will be like: Thu Jan 01, 1998. See man strftime for help with formatting.

cvtdat Month Day Year[format_string]


  • cvtdat 11 3 98 "%a %b %d, %Y (%j)"
    Tue Nov 03, 1998 (307)
image epoch2time.c


A utility to return a date in in the specified format, when the input value is elapsed seconds since epoch. Some unix utilities return "epoch time" as their results, and the purpose of this utility is to present that information in a more human-friendly fashion.

epoch2time value [format_string]


  • epoch2time 874420665
    Tue Sep 16 10:37:45 1997
image lsdate.tar


A utility by Andy Cranston to display the last modified date of one or more files down to the exact second in a consistent and hence easily parsed format.

lsdate [path][files]


  • lsdate .
    2001/02/04 18:15:18 bin
    2002/01/13 03:46:26 boot
    2002/04/23 19:27:46 dev
    2002/01/13 07:27:08 etc
    2001/12/30 20:09:41 home
    2001/02/04 18:14:10 lib
image rslvlnk.c


Resolves soft-link names to their hard-link equivalent.
Determines the hardlink name of any file, given the softlink name. Will trace down the "actual" name of any softlink, whether that link represents a directory name, regular file, or other filetype.

In the cases where links point to links such as:
aaa -> bbb -> ccc -> ... -> zzz
this program will report the final, or actual filename in the list.

Usage: rslvlnk linkname [linkname ...]


  • rslvlink /tmp/logfile1
  • rslvlink /tmp/logfile1 /tmp/logfile2
    /tmp/logfile1 -> /etc/appname/applogs/log05.log
    /tmp/linkname2 -> /var/spool/sundries/catalog_entries
image time2epoch.c


A utility by Bob Vance to return the epoch value.

No parameters: Current epoch value
Mth, Day, Yr, Hr, Min, Sec (all must be passed) returns epoch for that time.

time2epoch [mm dd yy hh mm ss]


  • time2epoch 7 31 2000 12 31 44
image unfind.c
Man page

A pipe by Andy Cranston to remove name files and directories from stdin.

command | unfind [ omit_entry ... ]
The unfind command is designed to be used as a pipe after the find command. The output of the find command (when used with the -print option) is piped into the unfind command. The arguments to unfind name files and/or directories which should be removed (i.e. 'unfound').

Exact matches are removed as expected. A line which looks like a sub-directory is also removed so sub-directories are, in effect, recursively removed. Filenames on stdin which do not satisfy the unmatching criteria are output on stdout unchanged.

A good use of unfind is to remove files found by find. For example, to remove the files under /dev from a file list which is to be used for a backup use something like this:
find / -print | unfind /dev | cpio ...
The resulting archive will NOT have any /dev special files in it.

There's no place like home
Is there a utility you'd like to see?
I may already have written it — or know
where to find it.
Write me to find out.

counter visitors since July 8, 2008

Last updated: Mar 09, 2021 at 06:23PM America/New_York