diff --git a/get-groups.sh b/get-groups.sh deleted file mode 100755 index 9a0ad62fb358416231c3338d704ca7665f3965b9..0000000000000000000000000000000000000000 --- a/get-groups.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# Usage: -# get-groups.sh username -# -# username is the name of the user you want to know the groups of - -# cat /etc/group | grep $USER | cut -d ":" -f 1 - -#Define user input -USERNAME=$1 - -function exist { - if [ $(grep -c ${USERNAME} /etc/passwd ) -eq 0 ];then - echo "Cet utilisateur n'existe pas" >&2 - exit 0 - fi -} - -function mainGroup { - local pass=$(cat /etc/passwd | grep ${USERNAME} | cut -d ":" -f 4) - echo $(cat /etc/group | grep ${pass} | cut -d ":" -f 1) -} - -function groups { - echo $(cat /etc/group | grep ${USERNAME} | cut -d ":" -f 1 | sed "/${USERNAME}/d") -} - -# Test for mandatory inputs -if [ -z "${USERNAME}" ];then - echo "Usage:" >&2 - echo -e "\t$0 username" >&2 - exit 0 -fi - -if [ !$(exist) ];then - echo $(mainGroup) $(groups) -fi