#!/bin/sh

if [ -z "$1" ]; then
    echo "You must define a groupname"
    echo "Usage: ./test.sh groupname"
    exit 1
fi

grps=`grep "GRPNAMES=" list.sh`
check=`echo "$grps" | grep "$1"`
checklast=`echo "$grps" | awk '{print $NF}' | tr -d '"'`

if [ -z "$check" ]; then
    echo "$1 does not exist, quitting"
    exit 1
fi

if [ "$1" == "$checklast" ]; then
    set -- $(echo " $grps " | sed "s/ $1//")
else
    set -- $(echo " $grps " | sed "s/$1 //")
fi

results="$*"

echo "$results"

exit 0
