62.1k views
4 votes
In this section of your final project, you will write a basic script to create and back up files. You will create this script with the vi editor. The script will combine multiple commands and simplify a repeatable task. Your script should be named Firstname Lastname.BASH. Your script and your Linux directory structure should demonstrate that you have correctly written the script to do the following: Create files: In this section, you will demonstrate your ability to utilize various Linux commands to create text files. Create these files in the NEW directory. Ensure that the commands in your log file show that the following three text files were created using three different methods. Create the following files

XI A. A text file listing the quantity of operating system free space, titledFree_Space Content.txt B. A text file listing the directory contents of the OLD folder, titled OLD_Content.txt C. A text file showing the current month, day, and time (Title this fileTime File.tx.)
XI Modify and Move files: Utilize Linux commands to copy files to a different directory and renamethem A. Copy the following selected files from the OLD directory to the BACKUP directory. Ensure that you change the filename suffix fro XXX OLD to XXX BACKUP i. Free_Space_Content OLD.txt ii Directory Content OLD.txt i Time File OLD.txt Move all files from the NEW directory to the BACKUP directory (no renaming necessary). Clean up the Linux directory structure by deleting the items in the NEW directory B.

2 Answers

8 votes

Answer:

####Bash Script Start###################################

#######Please check the permissions on the folders inorder to make sure the script works

#!/bin/bash

if [ ! -d NEW ]; then

mkdir -p NEW;

fi

df > "NEW/Free_Space_Content.txt"

touch "NEW/OLD_Content.txt" | ls -l OLD > "NEW/OLD_Content.txt"

> "NEW/Time_File.txt" | date +"%B %c" > "NEW/Time_File.txt"

cp "OLD"/*.txt "BACKUP"

rename OLD BACKUP "BACKUP"/*.txt

mv "NEW"/*.txt "BACKUP"

#############Bash Script End##################################

########Script_Assessment.txt#####################

Commands which were used to create files:

touch filename

command > filename

> filename

Directory and its contents:

NEW: Contained the newly created file

OLD: Contained sample files with OLD suffix

BACKUP: Contains all the files moved from NEW and OLD directories

Free_Space_Content.txt contains the disk info such as used and free space

OLD_Content.txt contains the directory contents info of OLD directory

Time_File.txt : Contais the current month, day and time info

Step-by-step explanation:

User James Kanze
by
7.5k points
6 votes

Answer:

bjdjdindbdubduf kndjnxjxjfujdjbdjbd bzjbd djbdibdu jdjdidnidndi xubdubdufjksk. xud ufbsjjdi djneibdudbdujfjfbjbdj fu. fjfjjdubdjjdbjd jdbdinkdkdnd. djjdibnfjdkndindundi jdudjbdubd djbdu bdudjdjjd djidndud dudbid anís us dj

User Xolve
by
7.2k points