November 23, 2024, 08:10:32 AM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Write a shell script capable of doing the following:  (Read 12581 times)

Offline ianwahome

  • New Member
  • Posts: 1
Write a shell script capable of doing the following:
« on: April 29, 2013, 01:21:07 AM »
1. Create a directory "preFinal" in your home directory. In case that such directory exist, rename the existing one into "preFinal.000" and then create empty directory preFinal. While renaming existing preFinal into preFinal.000 you may discover that preFinal.000 also exists, so it needs to be renamed into preFinal.001 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 result 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 scrip 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