-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirectory_management.sh
129 lines (128 loc) · 2.83 KB
/
directory_management.sh
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
#Navigation. Absolute/ Relative Pathnames. Listing Directories. Creating Directories. Modifying Directories.
echo "\n\t\t\tImplementing directory management\n\n"
while [ 1 ]
do
echo "\n\tMain Menu\n"
echo "1. Navigate into other directories"
echo "2. Change permission of directory"
echo "3. Listing of directory"
echo "4. Creating a new directory"
echo "5. Modifying a directory"
echo "6. Exit"
echo "\nEnter your choice: "
read choice
if [ $choice = 1 ]
then
while [ 1 ]
do
echo "\n\tSub-Menu\n"
echo "1. Move to parent directory: "
echo "2. Move to any child directory: "
echo "3. Move to root directory: "
echo "4. Move to Home directory: "
echo "5. Back to main menu\n"
echo "Enter your choice: "
read c
if [ $c = 1 ]
then
cd ..
echo "\nMoved to parent directory\n"
elif [ $c = 2 ]
then
echo "Enter name of the directory: "
read x
cd $x
echo "\nMoved to said directory\n"
elif [ $c = 3 ]
then
cd /
echo "\nMoved to root directory\n"
elif [ $c = 4 ]
then
cd ~
else
break
fi
echo "Current directory: `pwd`"
done
elif [ $choice = 2 ]
then
echo "Enter name of the directory: "
read x
echo "\nCurrent permissions of $x is `ls -ld $x`"
echo "\nEnter permissions of directory as per new permissions: "
echo "\nEnter permission for user(rwx): "
read u
echo "\nEnter permission for members of group: "
read g
echo "\nEnter permission for others: "
read o
chmod u=$u,g=$g,o=$o $x
echo "Updated permission of $x is `ls -ld $x`"
elif [ $choice = 3 ]
then
echo "\n\tSub-Menu\n"
echo "1. List of all files and folders with extra information"
echo "2. List of all files and folders without extra information"
read c
if [ $c = 1 ]
then
ls -l
else
ls
fi
elif [ $choice = 4 ]
then
echo "Enter name of a directory to be created: "
read x
mkdir $x
echo "\n\tCreated"
elif [ $choice = 5 ]
then
while [ 1 ]
do
echo "\n\tSub-Menu\n"
echo "1. Rename the directory"
echo "2. Move the directory"
echo "3. Copy the directory"
echo "4. Delete the directory"
echo "5. Back to main menu"
echo "Enter your choice: "
read c
if [ $c = 1 ]
then
echo "Enter directory name: "
read x
echo "Enter new name of the directory: "
read y
mv $x $y
echo "\tFile has been renamed"
elif [ $c = 2 ]
then
echo "Enter path to source directory: "
read x
echo "Enter path to destination directory: "
read y
mv $x $y
elif [ $c = 3 ]
then
echo "Enter path to source directory: "
read x
echo "Enter path to destination directory: "
read y
cp $x $y
elif [ $c = 4 ]
then
echo "Enter name of the directory to be deleted: "
read x
rmdir $x
else
break
fi
c=0
done
else
echo "Exited"
break
fi
done