0

The script should offer a menu with the following options:

● To create a backup copy of a script file.

  • The name of the backup copy should have backup after the name of the script and be date stamped e.g. Ass3Script_backup_10_11_2015.
  • It should be saved to your home directory using the Environment Variable for your home directory.
  • The script should error check that the file exists and is a normal file. If this is not the case then the script should allow the user to re-enter the filename until a valid filename is entered

● To create a date stamped log file called e.g. log_file_10_11_2015 containing:

  • A list of who is logged into the system,
  • The disk usage and
  • Your currently running processes.
  • The file should be saved to an existing directory called log_dir which should be situated off your home directory

● To create a copy of a file.

  • The file should be in your current directory (the name of the file to be given by the user)
  • The destination directory name to be given by the user.
  • The script should error check that the file exists and is a normal file. If this is not the case then the script should allow the user to re-enter the filename until a valid filename is entered.
  • The script should check that the destination directory exists. If this is not the case then the script should allow the user to re-enter the destination directory until a valid directory is entered.

● To move the location of a file in your current directory (the name and destination to be given by the user)

  • The script should error check that the file exists and is a normal file. If this is not the case then the script should allow the user to re-enter the filename until a valid filename is entered.
  • The script should check that the destination directory exists. If this is not the case then the script should allow the user to re-enter the destination directory until a valid directory is entered.

● This script should loop continuously until the user chooses to quit.

karel
  • 114,770
Mike
  • 1

1 Answers1

1

I won't write the whole answer but, parts you need come from this answer:

Bash script (updated) snippet:

# Running under WSL (Windows Subsystem for Ubuntu)?
if cat /proc/version | grep Microsoft; then
    Distro="WSL"
else
    Distro="Ubuntu"
fi

today=$( date +%Y-%m-%d-%A ) /mnt/e/bin/daily-backup.sh Daily-$(hostname)-$Distro-backup-$today

The file name generated by above code is:

Daily-alien-Ubuntu-16.04-Backup-2018-11-29-Thursday.tar.gz.64

Where:

  • $(hostname) produces alien (for an AW17R3 in case you are wondering).
  • $Distro produces Ubuntu (when not running under Windows 10).
  • $(lsb_release -sr) produces 16.04
  • $Today produces 2018-11-29-Thursday (Today's date)

You can find sample code for most of what you need to do all over this website and our sister website called Unix & Linux. There is a proliferate amount of code all over the internet as well.

It is best to just start writing your script and then when you run into problems with a specific line of code post a question on it. I would budget a week for you to get it done (just a wild guess-timate).