-
Notifications
You must be signed in to change notification settings - Fork 2
/
Carpetas_A-Z_con_Shell.sh
57 lines (49 loc) · 1.18 KB
/
Carpetas_A-Z_con_Shell.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
#!/usr/bin/env bash
# Realizar el ejercicio 1 del examen de PowerShell
clear
letras=(a b c d e f g h i j k l m n ñ o p q r s t u v w x y z)
for (( i=0; $i < ${#letras[@]}; i++ ))
do
mkdir /home/raul/prueba/${letras[${i}]}
done
echo "Carpetas creadas en /home/raul/prueba"
OIFS=$IFS
IFS=#
while read p1 p2 p3 p4 p5 p6
do
for (( j=0; $j < ${#letras[@]}; j++ ))
do
cd /home/raul/prueba/${letras[${j}]}
if [ ${letras[${j}]} = ${p1:0:1} ]
then
touch fichero.txt
echo ${p1} >> fichero.txt
fi
if [ ${letras[${j}]} = ${p2:0:1} ]
then
touch fichero.txt
echo ${p2} >> fichero.txt
fi
if [ ${letras[${j}]} = ${p3:0:1} ]
then
touch fichero.txt
echo ${p3} >> fichero.txt
fi
if [ ${letras[${j}]} = ${p4:0:1} ]
then
touch fichero.txt
echo ${p4} >> fichero.txt
fi
if [ ${letras[${j}]} = ${p5:0:1} ]
then
touch fichero.txt
echo ${p5} >> fichero.txt
fi
if [ ${letras[${j}]} = ${p6:0:1} ]
then
touch fichero.txt
echo ${p6} >> fichero.txt
fi
done
done < /home/raul/palabras.txt 2>>/dev/null
IFS=$OIFS