Thanks pk! That's the same thin Greg told me.
#!/bin/bash if [! -e b.txt]; then mv a.txt b.txt exit fi #The previous commands checks to see if b.txt is NOT already there, if NOT, it renames a.txt to b.txt #If the script gets here, b.txt EXISTS.......... # does_exist is a recursive function....looking at b.txt(i) ......the first b.txt(some number) it finds NOT existing...it creates.... set i = 1 does_exist[] if [-e b.txt.$i]; { then i = i +1 does_exist else mv a.txt b.txt.$i exit fi } I'm close but getting an eror near the last line....not really sure why.... ./test: line 25: syntax error near unexpected token `fi' ./test: line 25: `fi'