-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExercice_1.sh
75 lines (66 loc) · 3.13 KB
/
Exercice_1.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
#!/bin/bash
# Check if a root directory is specified as an argument
root_dir="${1:-.}"
# Create the directory and file structure
directories=(
"$root_dir/personnages/mascottes"
"$root_dir/personnages/super heros/femmes/cape"
"$root_dir/personnages/super heros/femmes/sans cape"
"$root_dir/personnages/super heros/hommes/cape"
"$root_dir/personnages/super heros/hommes/sans cap"
"$root_dir/personnages/super heros/femmes/cape/batgirl"
"$root_dir/personnages/super heros/femmes/cape/wonderwoman"
"$root_dir/personnages/super heros/femmes/sans cape/electra"
"$root_dir/personnages/super heros/femmes/sans cape/superwoman"
)
files=(
"$root_dir/personnages/mascottes/beastie"
"$root_dir/personnages/mascottes/bibendum"
"$root_dir/personnages/mascottes/mario"
"$root_dir/personnages/mascottes/sonic"
"$root_dir/personnages/super heros/hommes/cape/batman"
"$root_dir/personnages/super heros/hommes/cape/superman"
"$root_dir/personnages/super heros/hommes/cape/thor"
"$root_dir/personnages/super heros/hommes/sans cap/antman"
"$root_dir/personnages/super heros/hommes/sans cap/daredevil"
"$root_dir/personnages/super heros/hommes/sans cap/linuxman"
"$root_dir/personnages/super heros/hommes/sans cap/spiderman"
)
# Create directories
for dir in "${directories[@]}"; do
mkdir -p "$dir"
done
# Create files
for file in "${files[@]}"; do
touch "$file"
done
# Set permissions for directories
chmod 755 "$root_dir/personnages"
chmod 775 "$root_dir/personnages/mascottes"
chmod 755 "$root_dir/personnages/super heros"
chmod 755 "$root_dir/personnages/super heros/femmes"
chmod 775 "$root_dir/personnages/super heros/femmes/cape"
chmod 775 "$root_dir/personnages/super heros/femmes/cape/batgirl"
chmod 775 "$root_dir/personnages/super heros/femmes/cape/wonderwoman"
chmod 775 "$root_dir/personnages/super heros/femmes/sans cape"
chmod 775 "$root_dir/personnages/super heros/femmes/sans cape/electra"
chmod 775 "$root_dir/personnages/super heros/femmes/sans cape/superwoman"
chmod 755 "$root_dir/personnages/super heros/hommes"
chmod 775 "$root_dir/personnages/super heros/hommes/cape"
chmod 775 "$root_dir/personnages/super heros/hommes/sans cap"
# Set permissions for files
chmod 644 "$root_dir/personnages/mascottes/beastie"
chmod 644 "$root_dir/personnages/mascottes/bibendum"
chmod 644 "$root_dir/personnages/mascottes/mario"
chmod 644 "$root_dir/personnages/mascottes/sonic"
chmod 644 "$root_dir/personnages/super heros/hommes/cape/batman"
chmod 644 "$root_dir/personnages/super heros/hommes/cape/superman"
chmod 644 "$root_dir/personnages/super heros/hommes/cape/thor"
chmod 644 "$root_dir/personnages/super heros/hommes/sans cap/antman"
chmod 644 "$root_dir/personnages/super heros/hommes/sans cap/daredevil"
chmod 644 "$root_dir/personnages/super heros/hommes/sans cap/linuxman"
chmod 644 "$root_dir/personnages/super heros/hommes/sans cap/spiderman"
# Move linuxman to mascots directory and rename to tux
mv "$root_dir/personnages/super heros/hommes/sans cap/linuxman" "$root_dir/personnages/mascottes/tux"
# Display permissions using ls
ls -lR --color=auto "$root_dir/personnages"