Write a shell script capable of doing the following:
create a directory "preFinal" in your home directory. In case that such directory exist, rename the existing one ino "preFinaal.000" and then create empty directory preFianl. While renaming existing preFinal into preFinal.000 you may discover that preFianl.000 exists, so it needs to be renamed into preFinal.00 and so on.
create empty files "a", "b", "c", etc in directory preFinal in the amount that match the number of directories preFinal*.
Example:
Assume there are no directories preFinal* in your $HOME(very first run of the script). it will create directory preFinal and will create empty file "a" in it.
Second run of the same script will resulr in renaming preFinal into preFinal.000 and creating empty files "a", and "b" in preFinal. At the end of this run you will have empty file "a" in preFinal.000 and empty files "a" and "b" in preFinal
the 3rd run of the script will result in empty files "a","b","c" in preFinal, files "a","b" in preFinal.000 and "a" in preFinal.001
and so on.
Here is what I have done so far. I'm not sure what to do next.
#preFinal.sh
#copies preFinal to preFinal.000 if preFinal exist or preFinal.001 if preFinal.000 exists...
#
mkdir preFinal/a
preFinal=0
if [ ls '-d "$0" -gt 1' ]; then
mv "$0" "0.000+.001
mkdir "$0"
fi
i=5
echo preFinal.$(printf "%03d" $i)
fi
if [ ! -t $test ]; then
echo "Directory $test doesn't exist"
exit 1
fi