Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
X-Injected-Via-Gmane: http://gmane.org/
To: cygwin@cygwin.com
From: Andrew DeFaria <ADeFaria@Salira.com>
Subject: Re: suggestion for cygutils - usermod (was Re: howto change home
     path in /etc/passwd)
Date: Mon, 12 May 2003 14:52:04 -0700
Lines: 87
Message-ID: <b9p4t6$o3e$1@main.gmane.org>
References: <B5D0B243841E0B4BA7BFCE18D244FFA32A9F0E@intexchg.isdomain.intrsoft.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: usenet@main.gmane.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4b) Gecko/20030416 Thunderbird/0.1a
X-Accept-Language: en-us, en
In-Reply-To: <B5D0B243841E0B4BA7BFCE18D244FFA32A9F0E@intexchg.isdomain.intrsoft.com>

Bernard Kash wrote:

>"Igor Pechtchanski" <pechtcha@cs.nyu.edu> wrote in message
>news:<Pine.GSO.4.44.0305121055540.393-100000@slinky.cs.nyu.edu>...
>  
>
>>On Mon, 12 May 2003 Sylvain.Ferriol@imag.fr wrote:
>>
>>    
>>
>>>Surlignage Max Bowsher <maxb@ukf.net>:
>>>
>>>      
>>>
>>>>Sylvain.Ferriol@imag.fr wrote:
>>>>        
>>>>
>>>>>Yes , because i don't want to create a shell doing this: grep -v 
>>>>>$USERNAME /etc/passwd > /etc/passwd
>>>>>          
>>>>>
>>>sorry
>>>but i don't know with sed how to delete a line starting with $USER
>>>      
>>>
>>For the record: "sed '/'$USER':/d".  However, grep is perfectly 
>>adequate. What Max was warning you about was the shell redirection 
>>mechanism.  You'd be safer using something like
>>
>>  cp -p /etc/passwd /etc/passwd-bak-tmp && grep -v $USERNAME 
>>/etc/passwd-bak-tmp > /etc/passwd && rm -f /etc/passwd-bak-tmp
>>    
>>
>
>Unfortunately, if you have a user named Homer that uses
>'home' as his userid, the grep will eliminate more users
>than you might expect.  A more realistic example might be
>two users 'ted' and 'ed' when modifying user 'ed'.
>
OK then grep -v "^$USERNAME:" /etc/passwd-bak-tmp ...

>
>Also, the mkuser -p option expects a base directory,
>so if $HOME is "/home/usrname" the resulting record
>will set HOME to "/home/username/username" 
>
>I've used awk delete a user from passwd...
>
>awk -F: -v usr=$USERNAME '{IGNORECASE=1; if($1 != usr) print $1;}'
>/etc/passwd
>
>BB
>
>  
>
>>>>Care! That will leave you with an empty /etc/passwd.
>>>>The shell truncates /etc/passwd BEFORE grep reads it.
>>>>
>>>>        
>>>>
>>>>>mkpasswd -l -u $USERNAME -p $HOME >> /etc/passwd
>>>>>
>>>>>sylvain
>>>>>          
>>>>>
>>>>Max.
>>>>        
>>>>
>>Hope this helps,
>>	Igor
>>-- 
>>				http://cs.nyu.edu/~pechtcha/
>>      |\      _,,,---,,_		pechtcha@cs.nyu.edu
>>ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
>>     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
>>    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!
>>
>>Knowledge is an unending adventure at the edge of uncertainty.
>>  -- Leto II
>>
>>
>>    
>>
>
>  
>



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

