The exercise consists of evaluating the files contained in a directory, depending on whether they are:
- Directories
- Executable
- Device
- Regular files
My moment code is this:
# Clasificamos el contenido del directorio
# Contadores:
d=0
e=0
t=0
dv=0
# Recorremos el directorio actual
for entry in *
do
echo "$entry"
# Comprobamos si es un directorio
if [ -d "$entry" ]
then
((d = d + 1))
fi
# Comprobamos si es ejecutable
elif [ -x "$entry" ]
then
((e = e + 1))
fi
# Comprobamos si es un fichero de texto (regular)
elif [ -f "$entry" ]
then
((t = t + 1))
fi
done
I've been testing, and for now it's fine, but I can not find a way to check if a file is a device file (/ dev)