#!/bin/ksh # GetTempPathName.ksh # 2003-11-14 # Chieh Cheng # http://www.CynosureX.com/ # GNU General Public License (GPL), Version 2, June 1991 scriptname=`echo $0 | sed s/\\\\/.*\\\\///g` showUsage () { echo " Usage: $scriptname \"prefix\" [\"suffix\"] [\"directory\"]" } if [ $# -lt 1 ] || [ $# -gt 3 ] then showUsage exit fi prefix="$1" if [ $# -gt 1 ] then suffix="$2" else suffix=".tmp" fi if [ $# -eq 3 ] then directory="$3" else directory="/tmp" fi i=0 pathName="${directory}/${prefix}${suffix}" while [ -a "$pathName" ] do pathName="${directory}/${prefix}${i}${suffix}" ((i = i + 1)) done touch "${pathName}" echo "${pathName}"