Add script for listing /etc/passwd users

This commit is contained in:
raul 2025-01-15 10:08:40 +01:00
parent 460cf2d25b
commit 48b53ecf99
Signed by: raul
GPG Key ID: C1AA797073F17129
1 changed files with 29 additions and 0 deletions

29
class/scripts2/script1.sh Executable file
View File

@ -0,0 +1,29 @@
#!/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