Write a bash shell script to carry out each of the following tasks: a. Backup: A
ID: 3807474 • Letter: W
Question
Write a bash shell script to carry out each of the following tasks:
a. Backup:
Archive as a "tarball" (*.tar.gz file) all the files in your home directory tree (/home/your-name) that have been modified in the last 48 hours. Hint: use the command “find”.
b. Phone:
Write a shell script (called phone) that creates a simple telephone list (create an empty file called “phonelist” in your home directory). Each line in this file consists of two fields: a name and a phone number. The script shall do the following:
1. When the user types the command: “phone new name number” this will add new record (name, number) to the list.
2. When the user types the command: “phone name” then the script should search in the file “phonelist” and get the corresponding phone number and display the result.
Explanation / Answer
a. find . -mtime -2 | xargs tar --no-recursion -czf tarball.tgz
b.
#! /bin/sh
if [ "${1}" = "phone new" ]
then
echo "${2} ${3}" >> phonelist
else
cat phonelist | grep "${1}";
fi
exit 0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.