Operating System - HP-UX
1834814 Members
2952 Online
110070 Solutions
New Discussion

Re: cut, sed and awk - edit /etc/group

 
Aravind_3
Frequent Advisor

cut, sed and awk - edit /etc/group

How do i edit using sed,awk or cut make /etc/group in format to

users::20:user1,users2 .. user130

to the following format

users::20:user1,user2... user65
users::20:user66,useruser67 .. user130

Thanks
Aravind
6 REPLIES 6
Christian Gebhardt
Honored Contributor

Re: cut, sed and awk - edit /etc/group

Hi
you can separate the line with
sed 's/user65,/user65\^Jusers::20:/g' /etc/group

Attention: you can not copy and paste this line because the ^J is a "Cntrl-V Cntrl-J"

Chris
Aravind_3
Frequent Advisor

Re: cut, sed and awk - edit /etc/group

#!/bin/ksh
awk 'sub("user65,","user65\nuserA::20:")' file


john korterman
Honored Contributor

Re: cut, sed and awk - edit /etc/group

Hi,
try the attached script, using /etc/group as $1. If it does not work, please post a few lines of your input as attachment.

regards,
John K.
it would be nice if you always got a second chance
harry d brown jr
Honored Contributor

Re: cut, sed and awk - edit /etc/group


Try the attached perl program.

It will create a new group file without CLOBBERING the original, it's up to you to move them around (icd /etc;mv group orig_group;mv newgroup group)


live free or die
harry
Live Free or Die
James R. Ferguson
Acclaimed Contributor

Re: cut, sed and awk - edit /etc/group

Hi:

Attached you will find a script I wrote for the same purpose a while ago. It creates N-many '/tmp/group20.N' files each of up to 200 accounts by reading '/etc/passwd' and collecting all accounts belonging to group-20.

Run the script. Then edit '/etc/group' to remove the original group-20 specifications and insert the N-many '/tmp/group20.N' files created.

Regards!

...JRF...
Jordan Bean
Honored Contributor

Re: cut, sed and awk - edit /etc/group