Question

Your task is to create a tcsh shell script that is able to backup all the C program files in your current directory.
The algorithm is as follows:
• If a backup directory does not exist, then prompt the user if they would like to make one.
• If the user responds "y" or "yes" in either capitals or lowercase, then make the backup directory (in your current working directory)
• If the user responds "n" or "no" in either capitals or lowercase, then produce a message that no directory was created
• otherwise, print a message that an invalid response was entered
• If the backup directory exists
• For each .c file:
• If there have been changes to the file since the last backup, then copy the current .c file to the backup directory
• Else (if no copy exists in the backup directory) copy it
• (Otherwise, no copy will be made)
The following is a shell script that makes backups to a "backup" directory in your home directory: bckup.sh
You might want to take ideas from it, but note that it does not prompt you if you would like to make the directory.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#!/bin/tcsh

set backupDir=backupdir

echo "remove backupdir"
if ( -d $backupDir ) then
   rm -r $backupDir
endif

ls -l

echo "Type NO"
./backup.sh # Type "NO" to creating a backup directory
echo "Type n"
./backup.sh # Type "n" to creating a backup directory
echo "Type up"
./backup.sh # Type "up" to creating a backup directory
echo "Type yes"
./backup.sh # Type "yes" to creating a backup directory

ls -l $backupDir

echo "remove backupdir"
rm -r $backupDir

echo "Type Yes"
./backup.sh # Type "Yes" to creating a backup directory...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Computer Science Problems
Homework Solution
$30.00
Computer Science
Linux
C Programming Language
Kernel Source Tree
Systems
Numbers
Architecture
Integers
Input
Output
Strace Utility
Basic Commands
Algorithms
File Management
Compilers
Three Simple Shell Scripts
Homework Solution
$15.00
Shell
Bash
Script
List
Directory
Lsdirs
Sh
File
See
Wordlen
Type
Long
Word
Test
Read
Wc
Argument
Bourne
Computer Science Questions
Homework Solution
$75.00
Computer Science
Linux
Memory
CPU
Algorithms
Jobs
Percentage
Deadlock
Programmers
PCS Scheduling
SCS Scheduling
Resources
Vectors
Tasks
System Snapshots
Logical Addresses
Physical Addresses
Transfers
Get help from a qualified tutor
Live Chats