Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with the following below and I also added a picture below the question to show how the coding I am used to.

I need help with the following below and I also added a picture below the question to show how the coding I am used to. I am using vi to write the code. Thanks:

Write a shell script which: 1. accepts a file name (ask the user for the file) 2. checks if file exists 3. if file exists, copy the file to the same name + .bak + the current date (if the backup file already exists ask if you want to replace it). The syntax to copy a file is:

cp file1 file2 (this will copy file1 to file2)

When done you should have the original file and one with a .bak at the end.

For example, assume the file is called test.txt.

First time you make a backup the script will rename the file to test.txt.bak

Next time you try to backup test.txt, you need to ask if the user wants to backup the file since it already exists. If the answer is "no", no backup was created. If the answer is "yes" then copy the backup to test.txt.bak.current-date (current date should be formatted to just print year-mm-dd)

image text in transcribed

cat function.sh #1 bin/bash function check()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

3. What are potential solutions?

Answered: 1 week ago