Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Write a shell script capable of doing the following:

  1. 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.

  2. create empty files "a", "b", "c", etc in directory preFinal in the amount that match the number of directories preFinal*.

Example:

  1. 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.

  2. 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

  3. 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

  4. 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
share|improve this question
5  
What did you try? If you expected us to hand in your assignment for you, you forgot to include the email of your instructor. – Gilles May 1 at 23:54
Agreed, we aren't here to do your homework for you, try doing it yourself and if you get stuck we're more than happy to help, just not do! – slm May 1 at 23:55
I just added some of my code that i have so far. – Roseline May 2 at 0:13

closed as not a real question by Renan, Chris Down, Patrick, slm, MaxMackie May 2 at 1:37

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

Browse other questions tagged or ask your own question.