How to process the user id list in /etc/group?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to process the user id list in /etc/group?
# 1  
Old 02-13-2008
How to process the user id list in /etc/group?

To all,
I need to find a group in /etc/group and if found, I need to list out all the login ids for that group - one login id per line.

To find the list of user login ids for group X, I probably will use

cat /etc/group|grep ^X:|cut -d: -f4

This will return back a list of comma delimited login ids.

Here's my problem.

How do I print each login id on one line?

Or is there a better way of doing this?

Please help.
Thanks.
# 2  
Old 02-13-2008
Code:
$ echo a,b,c | tr ',' '\n'
a
b
c

That should help.
# 3  
Old 02-13-2008
Yup, that works.

Now that I have the report, my boss added a new requirement. He wants the user ID and the user's real name on the same line.

Any idea?

Thanks.
# 4  
Old 02-13-2008
That's simple. grep(1) for the uid in /etc/passwd and take the 5th field using cut(1).
# 5  
Old 02-13-2008
Yes, I know that's simple. I know how to get the name once I have a user id. My problem is I need to somehow scan thru the comma delimited user id list and retrieve one id at a time so that I can find the name in the passwd file.

My original command will give me the user login id list.

cat /etc/group|grep ^X:|cut -d: -f4

How do I scan thru this login id list, find the name for each of the ids, and print each id & name per line?

For example, the list of ids is ID1,ID2,ID3.

I want the report to show

ID1 John Doe
ID2 Jane Doe
ID3 John Smith

I hope this is clear. If not, let me know.
Thank you very much for your help.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Process split files with same name by group

File examples f17_mar_01_02_03_04_fsw1.xml f17_mar_01_02_03_04_fsw2.xml f17_mar_01_02_03_04_fsw3.xml f17_feb_13_20_49_06_fsw1.xml f17_feb_13_20_49_06_fsw2.xml f17_feb_13_20_49_06_fsw3.xml I have many xml files that are grouped with same file name, but are numbered from 1-to-many... (2 Replies)
Discussion started by: aachave1
2 Replies

2. Programming

Create a group of process

Hi all ! :) What I want? 1. All child process must be in the same group of process. Parent is a leader of the group. How to do this? I would be greatfull of some example of code, I read about setsid but I can't even start... My code so far: #include <stdio.h> #include <stdlib.h>... (2 Replies)
Discussion started by: mattdj
2 Replies

3. Shell Programming and Scripting

List Process running under current user

Hi, i need to list the processes running only under current logged in user. EX: $ whoami oraaqw $ ps -ef | grep tnslsnr oraaqw 11403300 19267592 0 09:14:47 pts/3 0:00 grep tnslsnr oraaqw 15794208 1 0 Jan 14 - 11:59... (6 Replies)
Discussion started by: aravindadla
6 Replies

4. Red Hat

User is a Part of a Group But Group Details Do Not Show the User

Hi, In the following output you can see the the user "richard" is a member on the team/group "developers": # id richard uid=10247(richard) gid=100361(developers) groups=100361(developers),10053(testers) but in the following details of the said group (developers), the said user... (3 Replies)
Discussion started by: indiansoil
3 Replies

5. Shell Programming and Scripting

List of process of user

Hi, I need an output of process running on server, i am executing ps -ef | grep test output is asak 22362 1 0 Nov07 ? 00:00:03 /usr/software/bin/perl-5.8.8 /u/assk/bin/test -v none JOBID=2012117 asak 23748 22362 0 Nov07 ? 00:00:00 /usr/software/bin/perl-5.8.8... (3 Replies)
Discussion started by: asak
3 Replies

6. Ubuntu

Create New User with the same group nd privileges of the other user

Hi, Anyone can help me on how to duplicate privileges and group for useroradb01 to userrootdb01. I have currently using "useroradb01" and create a newly user "userrootdb01". I want both in the sames privileges and group. Please see the existing users list below; drwxr-xr-x 53 useroradb01... (0 Replies)
Discussion started by: fspalero
0 Replies

7. Shell Programming and Scripting

script to monitor the process system when a process from user takes longer than 15 min run.

get email notification from from system when a process from XXXX user takes longer than 15 min run.Let me know the time estimation for the same. hi ,any one please tell me , how to write a script to get email notification from system when a process from as mentioned above a xxxx user takes... (1 Reply)
Discussion started by: kirankrishna3
1 Replies

8. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

9. AIX

How to allow group members to kill process?

Hey I'm writing a script that creates some processes,and some scripts which kill those processes. the question is Simply: How can I allow group members to be able to kill processes created by other member at the same group? I need your help as soon as possible Thanks for your help in... (4 Replies)
Discussion started by: The Dark Knight
4 Replies

10. Shell Programming and Scripting

how to kill a process initiated by other user at the same group

Hey I'm writing a script that creates some processes,and some scripts which kill those processes. the question is Simply: How can I allow a group members to be able to kill (using kill command) processes created by other user at the same group? and i need the change to be at the script... (5 Replies)
Discussion started by: The Dark Knight
5 Replies
Login or Register to Ask a Question