Kornshell function declarations

Over the years I have seen and maintained many kornshell scripts written by DBAs, and there are a number of programming styles that provoke strong reactions on who is doing it the "right" way. In this article, I will explain the different ways in which functions can be defined in Kornshell and explain why I personally prefer one method over another.

Continue SCP’ing file(s) after log out

The unix command scp is very useful for transferring files between two hosts over a secure connection, but sometimes you need to kick off an scp command that will take several hours to complete and you want to disconnect and go home. Using "screen" One approach is to use the screen command (available only on linux AFAIK) to start the initial transfer, then... Continue Reading →

Kornshell function to keep revisions of a file

Sometimes while developing scripts you want to keep backups of certain files, but are worried that over time the old versions will fill the filesystem and need housekeeping. The following function will allow you to keep only <n> versions of a file (the default is 5 backups) with older ones getting removed automatically.  # Usage:... Continue Reading →

Manipulating dates in KornShell

Sometimes you need to shift the current date and time by 24 hours, but unfortunately one of the things that KornShell is very poor at is the handling of dates and times. Here are some tips for getting and manipulating dates: Yesterday's date: TEMP_TZ=$TZ TZ=GMT+24 YESTERDAY=`date` TZ=$TEMP_TZ Tomorrow's date: TEMP_TZ=$TZ TZ=GMT-24 TOMORROW=`date` TZ=$TEMP_TZ If you... Continue Reading →

Blog at WordPress.com.

Up ↑