Re: Easy way to programatically change /etc/passwd

From: Bruce Whittaker (bwhittak@ENERGY.COM.AU)
Date: Tue Mar 18 2003 - 22:18:04 EST


Since the new entries would be added at the end of the file, would
something like the following help ?

Get the number of lines with

wc -l /etc/passwd

head -X /etc/passwd > /tmp/newpasswd (where X is the
number of lines in the file - 300)
tail -300 /etc/passwd | tr \! \* >> /tmp/newpasswd

If you wanted to take it further (ie, translate only a specific field
rather than all text), you could play with the cut command and see if it
helps you.

Cheers,

Bruce Whittaker,
CASS Support,
Extension 34193
External (02) 9269 4193.
----------------------------------------------------------------------------------------
This e-mail may contain confidential or privileged information. If you
have received it in error, please notify the sender immediately via return
e-mail and then delete the original e-mail. EnergyAustralia has collected
your business contact details for dealing with you in your business
capacity. More information about how we handle your personal information,
including your right of access is contained at http://www.energy.com.au.
----------------------------------------------------------------------------------------

pSeries AIX Geek <aixgeek@YAHOO.COM>
Sent by: IBM AIX Discussion List <aix-l@Princeton.EDU>
19/03/2003 02:43
Please respond to IBM AIX Discussion List

        To: aix-l@Princeton.EDU
        cc:
        Subject: Re: Easy way to programatically change /etc/passwd

I don't want to change EVERY ! to a *, only certain
ones. I.e., suppose I've dumped 300 new entries to
/etc/passwd; I only want to change the ! for those 300
entries.

--- Bruce Whittaker <bwhittak@ENERGY.COM.AU> wrote:
> Will this fix your problem ?
>
> cat /etc/passwd | tr \! \* > new_passwd
>
> Just be aware that all exclamation marks will be
> altered so first make
> sure that no doubles exist.
>
> Bruce Whittaker,
> CASS Support,
> Extension 34193
> External (02) 9269 4193.

__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:40 EDT