Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 38a74e6

Browse files
Update README.md
1 parent 2afe971 commit 38a74e6

File tree

1 file changed

+16
-71
lines changed

1 file changed

+16
-71
lines changed

‎README.md‎

Lines changed: 16 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,77 +3,22 @@ Hands-on Introduction to Linux Commands and Shell Scripting by IBM on Coursera
33

44
Finel Project File:
55
backup.sh:
6-
![17-crontab](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/c74aef5d-e2ad-4edf-8ded-6ed0964f3d64)
6+
![01-Set_Variables](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/d08cccc8-5ff4-4b41-9a5c-3f63666e7422)
7+
![02-Display_Values](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/49562877-b7b6-44d8-ab9a-a05ad3b3dc7b)
8+
![03-CurrentTS](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/61ed6460-099b-4599-8c0c-c69a450f40e4)
9+
![04-Set_Value](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/91e43590-5cef-4c9c-b694-dfd5ec568376)
10+
![05-Define_Variable](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/3c87310c-e863-4829-bbfd-4cc5f0dd2741)
11+
![06-Define_Variable](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/2778e1ea-0546-4dd4-b3af-24e0ec69946f)
12+
![07-Change_Directory](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/b3701252-2513-418d-a3b9-d2337d2b7972)
13+
![08-YesterdayTS](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/64907312-148b-42d9-93ae-b46b0a5426d7)
14+
![09-List_AllFilesandDirectoriess](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/befbb581-1b77-4bc8-9144-fc1fb8bc2388)
15+
![10-IF_Statement](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/204ea99a-4e67-4b62-a4a0-680a1269c763)
16+
![11-Add_File](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/b983b00b-d2c2-44e9-8a93-5db81fb4cee3)
17+
![12-Create_Backup](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/b03ff4a9-e4b7-41ac-91d0-929d552f8194)
18+
![13-Move_Backup](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/da0572e2-90e6-42b1-92bf-93daaa9b6e86)
19+
![15-executable](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/c108c645-3d86-4a48-a0a5-8e2042b8ecce)
20+
![16-backup-complete](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/a2953e8f-de51-4b86-b46f-feffb53b4d97)
21+
![17-crontab](https://github.com/jaydattpatel/Linux-commands-and-Shell-Scripts/assets/124486498/aadbfd38-52e5-4fb3-b644-f87d194e16f7)
722

8-
#!/bin/bash
923

10-
# This checks if the number of arguments is correct
11-
# If the number of arguments is incorrect ( $# != 2) print error message and exit
12-
if [[ $# != 2 ]]
13-
then
14-
echo "backup.sh target_directory_name destination_directory_name"
15-
exit
16-
fi
17-
18-
# This checks if argument 1 and argument 2 are valid directory paths
19-
if [[ ! -d 1ドル ]] || [[ ! -d 2ドル ]]
20-
then
21-
echo "Invalid directory path provided"
22-
exit
23-
fi
24-
25-
# [TASK 1]
26-
targetDirectory=1ドル
27-
destinationDirectory=2ドル
28-
29-
# [TASK 2]
30-
echo "targetDirectory is 1ドル"
31-
echo "destinationDirectory is 2ドル"
32-
33-
# [TASK 3]
34-
currentTS=$(date +%s)
35-
36-
# [TASK 4]
37-
backupFileName="backup-$currentTS.tar.gz"
38-
39-
# We're going to:
40-
# 1: Go into the target directory
41-
# 2: Create the backup file
42-
# 3: Move the backup file to the destination directory
43-
44-
# To make things easier, we will define some useful variables...
45-
46-
# [TASK 5]
47-
origAbsPath=$(pwd)
48-
49-
# [TASK 6]
50-
cd $destinationDirectory
51-
destAbsPath=$destinationDirectory
52-
53-
# [TASK 7]
54-
cd $origAbsPath
55-
cd $targetDirectory
56-
57-
# [TASK 8]
58-
yesterdayTS=$(($currentTS - 24 * 60 * 60))
59-
60-
declare -a toBackup
61-
62-
for file in $(ls) # [TASK 9]
63-
do
64-
# [TASK 10]
65-
if ((`date -r $file +%s` > $yesterdayTS))
66-
then
67-
# [TASK 11]
68-
toBackup+=($file)
69-
fi
70-
done
71-
72-
# [TASK 12]
73-
tar -czvf $backupFileName ${toBackup[@]}
74-
75-
# [TASK 13]
76-
mv $backupFileName $destAbsPath
77-
78-
# Congratulations! You completed the final project for this course!
7924

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /