Sponsored Content
Full Discussion: Append users if GID exists
Top Forums Shell Programming and Scripting Append users if GID exists Post 302714829 by MaindotC on Friday 12th of October 2012 08:39:12 PM
Old 10-12-2012
I figured it out before I was able to consider some of your suggestions Smilie I grep the destination file to see if the GID already exists in the file that I store that in a variable. If that variable is empty then I append the GID definition to the bulkload file. If the variable is not null then I remove the line that contains the GID definition and then replace it with the same thing but with the user's id appended at the end.

Probably not very efficient as DGPickett points out...I may have to try a different logic as we increase in numbers.
 

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
GROUPMOD(8)						    System Management Commands						       GROUPMOD(8)

NAME
groupmod - modify a group definition on the system SYNOPSIS
groupmod [options] GROUP DESCRIPTION
The groupmod command modifies the definition of the specified GROUP by modifying the appropriate entry in the group database. OPTIONS
The options which apply to the groupmod command are: -g, --gid GID The group ID of the given GROUP will be changed to GID. The value of GID must be a non-negative decimal integer. This value must be unique, unless the -o option is used. Users who use the group as primary group will be updated to keep the group as their primary group. Any files that have the old group ID and must continue to belong to GROUP, must have their group ID changed manually. No checks will be performed with regard to the GID_MIN, GID_MAX, SYS_GID_MIN, or SYS_GID_MAX from /etc/login.defs. -h, --help Display help message and exit. -n, --new-name NEW_GROUP The name of the group will be changed from GROUP to NEW_GROUP name. -o, --non-unique When used with the -g option, allow to change the group GID to a non-unique value. -p, --password PASSWORD The encrypted password, as returned by crypt(3). Note: This option is not recommended because the password (or encrypted password) will be visible by users listing the processes. You should make sure the password respects the system's password policy. -R, --root CHROOT_DIR Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory. CONFIGURATION
The following configuration variables in /etc/login.defs change the behavior of this tool: MAX_MEMBERS_PER_GROUP (number) Maximum members per group entry. When the maximum is reached, a new group entry (line) is started in /etc/group (with the same name, same password, and same GID). The default value is 0, meaning that there are no limits in the number of members in a group. This feature (split group) permits to limit the length of lines in the group file. This is useful to make sure that lines for NIS groups are not larger than 1024 characters. If you need to enforce such limit, you can use 25. Note: split groups may not be supported by all tools (even in the Shadow toolsuite). You should not use this variable unless you really need it. FILES
/etc/group Group account information. /etc/gshadow Secure group account information. /etc/login.defs Shadow password suite configuration. /etc/passwd User account information. EXIT VALUES
The groupmod command exits with the following values: 0 success 2 invalid command syntax 3 invalid argument to option 4 specified group doesn't exist 6 specified group doesn't exist 9 group name already in use 10 can't update group file SEE ALSO
chfn(1), chsh(1), passwd(1), gpasswd(8), groupadd(8), groupdel(8), login.defs(5), useradd(8), userdel(8), usermod(8). shadow-utils 4.1.5.1 05/25/2012 GROUPMOD(8)
All times are GMT -4. The time now is 02:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy