I'm new here and I'm trying to learn some Bash. I need to write a script that will print all of users from etc/passwd in seperated lines from one, selected group defined as a $1 parameter.
When group does not exist, the proper message is displayed. Same for wrongly entered numbers. I manage to do this, which do all the job with messages, but I just can't find the way to write users from one group.
Example:
myscript.sh 1000
Output:
User1
User2
User3
Here's the bash file:
#!/bin/bash
awk -F':' '{ print $3 }' /etc/passwd | sort > list.txt
re='^[0-9]+$'
if grep -Fxq "$1" list.txt
then
**echo "don't know what to do here"**
else
if ! [[ $1 =~ $re ]] ; then
echo "Wrong number"
else
echo "Group does not exist"
fi
fi