Path: utzoo!attcan!uunet!cs.utexas.edu!usc!sdsu!ucsd!ogccse!littlei!omepd!merlyn From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.unix.questions Subject: Re: Sed to make global replacements. Message-ID: <5306@omepd.UUCP> Date: 2 Dec 89 17:37:58 GMT References: <37090@ames.arc.nasa.gov> Sender: news@omepd.UUCP Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Hillsboro, Oregon, USA Lines: 27 In-reply-to: gahooten@orion.arc.nasa.gov (Gregory A. Hooten) In article <37090@ames.arc.nasa.gov>, gahooten@orion (Gregory A. Hooten) writes: | I am working with sed on a file, and need to make a global replacement, but | what I am replacing are special characters to sed. I do not know how to | replace them. | | I would like to change the characters \(12 to 1/2, but every thing I try | thinks the \( is the start of a character group. I would like any help | possible on this problem. In sed, you need to escape the backslash, as in: % sed 's,\\(12,1/2,g' new Now, with Perl (of course, you knew it was coming :-), if you had a whole directory full of these files, you could perform this substitution, saving the original files as filename.bak, with: % perl -p -i.bak -e 's,\\(12,1/2,g;' * Cool, eh? No fuss, no muss, and all in one process. Just another Perl hacker, waiting for comp.lang.perl... -- /== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\ | on contract to Intel's iWarp project, Hillsboro, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn | \== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/