apunkabollywood
asked on
Linux - members in group less than 99
Member of groups which have gid less than 99 ( root or any ) , I need a command that will give me output of the usere which are in this groups
Please help me with the command
Please help me with the command
Assuming all users are in /etc/passwd you could use this grep:
grep -E .*\:.*\:.*\:\([0-9][0-9]\| [0-9]\)\:. * /etc/passwd | cut -d: -f1
This expression will include gids <=99 not <99. I suspect this is what you want though.
grep -E .*\:.*\:.*\:\([0-9][0-9]\|
This expression will include gids <=99 not <99. I suspect this is what you want though.
Hi... again
Maybe I should read the whole ;)
This fits :)
#!/bin/bash
IFS="
"
for i in `cat /etc/passwd`
do
let j=`echo $i | cut -f 4 -d ':' 2>/dev/null`
if [ $j -le "99" ]; then
echo $i|awk -F":" '{ print "Username: " $1 "\t\tGID:" $4 }'
fi
done
regards
'Adder
Maybe I should read the whole ;)
This fits :)
#!/bin/bash
IFS="
"
for i in `cat /etc/passwd`
do
let j=`echo $i | cut -f 4 -d ':' 2>/dev/null`
if [ $j -le "99" ]; then
echo $i|awk -F":" '{ print "Username: " $1 "\t\tGID:" $4 }'
fi
done
regards
'Adder
Just one beautification to output, Idea/Script is same as BlackAdder
#!/bin/bash
IFS="
"
for i in `cat /etc/passwd`
do
let j=`echo $i | cut -f 4 -d ':' 2>/dev/null`
if [ $j -le "99" ]; then
echo $i|awk -F":" '{ print "GID: " $4 "\t\tUsername: " $1 }'
fi
done |
sort -n -k2
_J
#!/bin/bash
IFS="
"
for i in `cat /etc/passwd`
do
let j=`echo $i | cut -f 4 -d ':' 2>/dev/null`
if [ $j -le "99" ]; then
echo $i|awk -F":" '{ print "GID: " $4 "\t\tUsername: " $1 }'
fi
done |
sort -n -k2
_J
#!/bin/bash
IFS="
"
for i in `cat /etc/passwd`
do
let j=`echo $i | cut -f 4 -d ':' 2>/dev/null`
if [ $j -le "99" ]; then
echo $i|awk -F":" '{ print "GID: " $4 "\t\tUsername: " $1 }'
fi
done |
sort -n -k2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The following script should do the trick:
let userid=100
IFS="
"
for i in `cat /etc/passwd`
do
let j=`echo $i | cut -f 3 -d ':' 2>/dev/null`
if [ $j -le $userid ]
then
echo $i|awk -F":" '{ print "Username: " $1 "\t\tUID:" $3 }'
fi
done
'Adder