scripts-random/01_bash/lineas_fichero.sh

25 lines
429 B
Bash
Raw Permalink Normal View History

2024-02-24 00:21:04 +01:00
#!/bin/bash
2024-02-22 21:02:37 +01:00
# Colores
BLUE="\033[34m"
RED="\033[31m"
NOCOLOR="\033[0m"
# Control de salida con Ctrl + C
function ctrl_c() {
2024-02-24 00:21:04 +01:00
echo -e "${RED}\n\n[!] Saliendo... \n${NOCOLOR}"
tput cnorm
exit 1
2024-02-22 21:02:37 +01:00
}
# Ctrl+C
trap ctrl_c SIGINT
# Main
for fichero in $(ls); do
if [[ -f "$fichero" ]]; then
cuenta=$(cat "$fichero" | wc -l)
2024-02-24 00:21:04 +01:00
echo -e "El fichero ${BLUE}$fichero ${NOCOLOR}tiene ${RED}$cuenta ${NOCOLOR}lineas"
fi
2024-02-22 21:02:37 +01:00
done