-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfiles
133 lines (133 loc) · 5.74 KB
/
files
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
while :
do
clear
echo "_________________________________________________________________________________________"
echo "|_______________________________________________________________________________________|"
echo "||_____________________________________________________________________________________||"
echo "||| |||"
echo "||| FILES |||"
echo "||| |||"
echo "||| 1. CREATE DIRECTORY |||"
echo "||| |||"
echo "||| 2. COPY FILES |||"
echo "||| |||"
echo "||| 3. MODIFY PERMITS TO A FILE |||"
echo "||| |||"
echo "||| 4. DISPLAY THE CONTENT OF A FILE |||"
echo "||| |||"
echo "||| 5. DELETE A FILE |||"
echo "||| |||"
echo "||| 6. CHANGE THE FILE'S NAME |||"
echo "||| |||"
echo "||| 9. RETURN |||"
echo "||| |||"
echo "||| |||"
echo "||| |||"
echo "||| 0000___000 |||"
echo "||| Please select desired option index 00000__000 |||"
echo "||| 000_000000 |||"
echo "||| 000__00000 |||"
echo "||| 000___0000 |||"
echo "|||___________________________________________________________________________________|||"
echo "||_____________________________________________________________________________________||"
echo "|_______________________________________________________________________________________|"
read option
case $option in
1) echo "Enter the name of the directory to be created and Press ENTER";
read directory;
if test -d $directory
then
echo "Error, the directory $directory already exist"
else
mkdir $directory
echo "The directory $directory has been created correctly"
fi; echo "Press ENTER to continue"; read lol;;
2) echo "Enter the file name you want to copy and Press ENTER";
read origin;
if test -f $origin;
then
echo "Enter the name of the new copy and Press ENTER"
read destiny
if test -f $destiny
then
while :
do
echo "The file $destiny already exist, Do you want to replace it? (yes/no)"
read selection
case "$selection" in
"yes") cp $origin $destiny; echo "The copy has been created correctly"; break;;
"no") break;;
*) echo "Typing error"; sleep 1;;
esac
done
else
cp $origin $destiny
echo "The copy has been created correctly"
fi
else
echo "Error, the file $origin doesn't exist"
fi;
echo "Press ENTER to continue";
read nothing;;
3) sh permissions; exit;;
4) echo "Enter the file name to display its content";
read fileName;
if test -f $fileName
then
if test -s $fileName
then
echo "The contents of the file $fileName is the following:"
cat $fileName
echo "Press ENTER to continue"
read nothing
else
echo "Error, the file $fileName is empty"
sleep 2
fi
else
echo "Error, the file $fileName doesn't exist"
sleep 1
fi;;
5) echo "Enter the name of the file to delete";
read fileName;
if test -f $fileName;
then
rm -rf $fileName
echo "The file $fileName has been deleted correctly"
echo "Press ENTER to continue"
read nothing
else
echo "Error, the file $fileName doesn't exist"
sleep 1
fi;;
6) echo "Enter the name of the file to change";
read fileName;
if test -f $fileName;
then
echo "Enter the new name of the file"
read newName
if test -f $newName
then
while :
do
echo "The file $newName already exist, Do you want to overwrite it?? (yes/no)"
read optionSelected
case "$optionSelected" in
"yes") mv $fileName $newName; echo "The file has been overwrited correctly"; break;;
"no") break;;
*) echo "Typing error"; sleep 1;;
esac
done
else
mv $fileName $newName; echo "The file $fileName has been modified correctly"
fi
echo "Press ENTER to continue"
read nothing
else
echo "Error, the file $fileName doesn't exist"
sleep 1
fi;;
9) sh menu; exit;;
*) echo "Error de Digitación"; sleep 1;;
esac
done