From 48b53ecf99dbb6db9801ee3761931dfadbdbda65 Mon Sep 17 00:00:00 2001 From: raul Date: Wed, 15 Jan 2025 10:08:40 +0100 Subject: [PATCH] Add script for listing /etc/passwd users --- class/scripts2/script1.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 class/scripts2/script1.sh diff --git a/class/scripts2/script1.sh b/class/scripts2/script1.sh new file mode 100755 index 0000000..adc9da6 --- /dev/null +++ b/class/scripts2/script1.sh @@ -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