Script now compatible with KSH/dash.