Answer:
Hi! The requirement of this question is a simple shell script that makes a copy of a file if it exists in the directory. The main command for this is "cp <file_to_copy> <copy_filename>"
Explanation:
We can write a code below to implement this in a file called "backup_script". The first argument to the script is taken as the fie_name. Then a check is done to see if the file exists with the "[-f file_name]" code, and the file is copied with a ".bak" if true. A success message is finally printed out to the user.
./backup_script
#! /bin/bash
set file_name = $1
if [ -f file_name ]; then
cp file_name file_name.bak
fi
if [ -f file_name.bak ]; then
echo "File successfully copied"
fi