Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!romp!auschs!awdprime!doorstop.austin.ibm.com!tif From: tif@doorstop.austin.ibm.com (Paul Chamberlain) Newsgroups: comp.unix.shell Subject: Re: sed help Message-ID: <4479@awdprime.UUCP> Date: 5 Dec 90 23:05:24 GMT References: <99.2757f296@vax1.cc.lehigh.edu> Sender: news@awdprime.UUCP Reply-To: tif@doorstop.austin.ibm.com (Paul Chamberlain) Organization: IBM AWD, Austin, TX Lines: 19 Summary: Expires: Sender: Followup-To: Keywords: In article <99.2757f296@vax1.cc.lehigh.edu> lubkt@vax1.cc.lehigh.edu writes: > I want to replace a string xyz:KJSDKJSDJS: by xyz:: in a >password file. The string "KJSDKJSDJS" is arbitrary. So I try: > sed -e 's/xyz:\??:/xyz::' $passwd I have no idea what "\??" is supposed to do but this should work: sed -e 's/xyz:[^:]*:/xyz::/' $passwd But this probably isn't what you want since this also will change a line with "somethingxyz:KJSDKJSDJS:". You might even want a more general and more mischevious command like: sed -e 's/^\([^:]*\):[^:]*:/\1::/' $passwd This wil remove the passwords on ALL users. The expression "[^:]*" matches the longest string that does not contain a colon. A common mistake would be to use an expression that matches more than that. Paul Chamberlain | I do NOT represent IBM. IBM VNET: sc30661 at ausvm6 512/838-9662 | This is rumored to work now --> tif@doorstop.austin.ibm.com