Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!ogicse!zephyr.ens.tek.com!tektronix!nosun!qiclab!onion!jeff From: jeff@onion.pdx.com (Jeff Beadles) Newsgroups: comp.unix.shell Subject: Re: sed help Message-ID: <1990Dec5.181729.8418@onion.pdx.com> Date: 5 Dec 90 18:17:29 GMT References: <99.2757f296@vax1.cc.lehigh.edu> Lines: 26 In <99.2757f296@vax1.cc.lehigh.edu> lubkt@vax1.cc.lehigh.edu writes: >A question on sed: > 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 guess the regular expression \?? should match any string, but does >not work. I know I am goofing somewhere. Any hints? Thanks. This should do what you want: sed 's/xyz:[^::][^::]*:/xyz::/' /etc/passwd Some versions of sed might not need two ':''s in the "[^::]". The version that I'm running here complains about non-match strings that are only one character long, sigh... The '?' character is not special with sed. The '.' is to sed, what the '?' is to the shell. Your example would change 'xyz:??abc' to 'xyz:abc'. Hope this helps, -Jeff -- Jeff Beadles jeff@onion.pdx.com