bash-exercises/show_users.sh

30 lines
448 B
Bash
Executable File

#!/bin/bash
USUARIO=$1
TITULOS=( "Nombre" "Contraseña" "UID" "GID" "Comentario" "Directorio Home" "Shell" )
# if [[ -z $USUARIO ]]; then
# echo "Usage: ./script1.sh root"
# exit
# fi
#
getUserInfo() {
USER=$1
IFS=':'
COUNT=0
for v in $USER; do
echo "${TITULOS[$COUNT]}: $v"
let COUNT++
done
}
main() {
while read -r v; do
# I hate this
getUserInfo "$v"
echo "--------------------"
done</etc/passwd
}
main