-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbk.sh
More file actions
32 lines (26 loc) · 696 Bytes
/
bk.sh
File metadata and controls
32 lines (26 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# Ask for a confirm
while [ -z $prompt ];
do read -p "Do you want to make a backup? (y/n)?" choice;
case "$choice" in
y|Y ) break;;
n|N ) exit 0;;
esac;
done;
# Ask the name of the folder to bk
read -e -p "Type the name of the folder to backup or drag and drop it on the terminal : " dir
# Eval the variable to combine arguments into a single string
eval dir="$dir"
# Ask the name of the bk folder
read -e -p "Select the name of the backup folder : " backdir
# Create the bk folder
mkdir "$backdir"
# Copy the folder
cp -r "$dir" "$backdir"
# Print the result
if [ $? == 0 ]
then
echo "$dir succesfully copied"
else
echo "Error, not copied!"
fi