#!/bin/bash
#FAUGERON Tylan & CHALENCON Yoan TD1 TPB

if test $# = 1
then
    if id -u $1 >/dev/null  2>/dev/null
    then
        num_user="$(id -u $1)"
        num_group="$(id -g $1)"
        name="$(pinky -l $1 | grep "Nom réel" | cut -d ':' -f 3 | xargs)"
        rep="$(pinky -l $1 | grep "Répertoire" | cut -d ':' -f 2 | xargs | cut -d ' ' -f 1)"
        inter="$(pinky -l $1 | grep "Répertoire" | cut -d ':' -f 3 | xargs)"
        echo "$1:x:$num_user:$num_group:$name:$rep:$inter"
    else
        echo "Utilisateur inconnu '$1'"
        exit 1
    fi
else
    echo "Usage : passUser login"
    exit 1
fi