Question
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)
cat function.sh #1 bin/bash function check()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started