Sponsored Content
Full Discussion: Append users if GID exists
Top Forums Shell Programming and Scripting Append users if GID exists Post 302711347 by scottaazz on Friday 5th of October 2012 07:59:09 PM
Old 10-05-2012
You could use something like the following:

Code:
awk -F':' '{ idx=$1":"$2":"$3":"; rec[idx]=rec[idx]","$4 } END {for (var in rec) print var substr(rec[var],2) }' YOURGIDFILE

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

append 3 users in /etc/passwd

I am looking to add 3 lines in /etc/passwd via a script. Can you please give me an idea on how to write a script that can do that? (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

2. UNIX for Advanced & Expert Users

GID & UID for HP-UX ?

Hi, can somebody tell me how to make directoriy in which all files will be generated as dir owner ? I'm able to add GID for directory group and files have group id like folder , but when i do same for user files still are created as user which creates them :( drwsrwsrwx 2 flexbul ... (2 Replies)
Discussion started by: pp56825
2 Replies

3. UNIX for Dummies Questions & Answers

rm: Unable to remove directory /mnt/users/test/logs/: File exists

rm: Unable to remove directory /mnt/users/test/logs/: File exists ls -latr total 191208 drwxrwxrwx 6 test echo 4096 Jul 3 22:36 .. -rwxrwxrwx 1 test echo 97692804 Jul 3 22:36 .nfsDFA4 drwxrwxr-x 2 test echo 4096 Jul 3 23:00 . M not able to delete... (4 Replies)
Discussion started by: solitare123
4 Replies

4. Shell Programming and Scripting

find, if exists then append for file with same name

I will have to process multiple files with same name everyday. My requirement is: If on a certain day I see that filename.txt exists then the contents of the filename.txt would be added/append to the former file contents.Each time it sees the file the content would be added.But the header ... (8 Replies)
Discussion started by: RubinPat
8 Replies

5. AIX

script for finding all the users with GID 0 ( admin group )

Hi Friends, I am trying to write a script for finding all the users with the GID 0 i.e. Admin users. can you please help me on this. (1 Reply)
Discussion started by: anoopraok
1 Replies

6. UNIX for Dummies Questions & Answers

Get the gid from a group name

Hi there, One can easily retrieve the uid from a username : id -u $username But how can we easily retrieve the gid from a group name? I mean is there a command without using sed? sed -nr "s/^$groupname:x:(+):.*/\1/p" /etc/group Thanks for your help Santiago (7 Replies)
Discussion started by: chebarbudo
7 Replies

7. UNIX for Dummies Questions & Answers

uid ,gid value change

Present /home/dsadm# id dsadm uid=0(root) gid=0(root) ---------------------------------- needs to be /home/dsadm> id dsadm uid=23186(dsadm) gid=16284(gdstage) Please provide the command/steps for the above uid, gid value change Thanks in advance for all your support . ... (3 Replies)
Discussion started by: sridhardwh
3 Replies

8. Shell Programming and Scripting

File exists, but cannot be opened.How to check- whether it could be opened to read when it exists

Hi #Testing for file existence if ; then echo 'SCHOOL data is available for processing' else echo 'SCHOOL DATA IS NOT AVAILABLE FOR PROCESSING' : i wrote a script, where it begins by checking if file exists or not. If it exists, it truncates the database... (2 Replies)
Discussion started by: rxg
2 Replies

9. Shell Programming and Scripting

Find users with root UID or GID or root home

I need to list users in /etc/passwd with root's GID or UID or /root as home directory If we have these entries in /etc/passwd root:x:0:0:root:/root:/bin/bash rootgooduser1:x:100:100::/home/gooduser1:/bin/bash baduser1:x:0:300::/home/baduser1:/bin/bash... (6 Replies)
Discussion started by: anil510
6 Replies

10. Homework & Coursework Questions

Display info about users (UID GID processes terminal)

I would like to get an opinion for my solution for this task and get feedback about better approach or mistakes I have made. 1. The problem statement, all variables and given/known data: The task is to create a script which prints information about users whose names are specified in the... (2 Replies)
Discussion started by: kornfan
2 Replies
addgroup(8)						      System Manager's Manual						       addgroup(8)

NAME
addgroup - Adds a new group interactively SYNOPSIS
/usr/sbin/addgroup DESCRIPTION
Security Note If you have enhanced security installed on your system, you should use the dxaccounts program to add a group. See Security and the dxac- counts(8) reference page for more information. The addgroup command is an interactive program for adding new groups to the /etc/group file. The program prompts you for specific informa- tion and informs you of its activity and error conditions. Only the superuser can execute this command. The program performs the following tasks: Queries for a new group name. The default can be chosen by pressing the Return key, which will cause the program to exit without adding a new group. Enter the new group name, 8 characters or less, or Return to exit. If the new group entered already exists in the /etc/group file, the program informs you of this and cycles back to the query for a new group name. If the new group entered does not already exist, the program continues. Queries for a group number (GID) for the new group. A default GID, which is based on previously existing GID's in the /etc/group file, is displayed and can be selected by pressing the Return key. Enter a new GID or accept the default. If the new GID entered already exists in the /etc/group file, the program informs you of this and cycles back to the query for a new group number (GID). If the new GID entered does not already exist in the /etc/group file, the program uses this GID and adds the new group to the /etc/group file. At this point, the program ends. This interface has been superseded by the groupadd command-line interface, and the Account Manager (dxaccounts) graphical user interface. RESTRICTIONS
The group name is limited to eight characters. EXAMPLES
Enter a new group name or <Return> to exit: newgroup Enter a new group number [112]: FILES
Specifies the command path. Group file Lock file SEE ALSO
Commands: adduser(8), dxaccounts(8), groupadd(8), removeuser(8) Files: group(4) addgroup(8)
All times are GMT -4. The time now is 03:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy