Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!husc6!ogccse!littlei!omepd!merlyn From: merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) Newsgroups: comp.unix.questions Subject: y/a-z/A-Z/ (was Re: sed: how to capitalize replacement text?) Keywords: sed Message-ID: <4268@omepd.UUCP> Date: 4 Apr 89 15:15:17 GMT References: <426b0af2.142c4@retina.engin.umich.edu> Sender: news@omepd.UUCP Reply-To: merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) Distribution: na Organization: Stonehenge; netaccess via BiiN, Hillsboro, Oregon, USA Lines: 23 In-reply-to: brian@caen.engin.umich.edu (Brian Holtz) In article <426b0af2.142c4@retina.engin.umich.edu>, brian@caen (Brian Holtz) writes: | | Is there a way to uppercase the pattern text in the replacement text | with sed's substitute command? In ex/vi, you just say | s/regexp/\U&/ | but not, apparently, in sed/ed. You can capitalize *all* of the sed pattern space with y/a-z/A-Z/ which is not in the sed paper (if I remember right) but is tucked away on the sed manpage. To capitalize just a regexp takes a bit of work with sed. Use perl instead :-), as in: s/(regexp)/($y = $1) =~ y|a-z|A-Z|, $y/eg; (Thanks, Larry Wall...) -- /=====Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095========\ { on contract to BiiN (for now :-) Hillsboro, Oregon, USA. } {<@intel-iwarp.arpa:merlyn@intelob.intel.com> ...!uunet!tektronix!biin!merlyn } \=====Cute quote: "Welcome to Oregon... home of the California Raisins!"======/