From owner-freebsd-questions Sun Jan 23 17:47:21 2000 Delivered-To: freebsd-questions@freebsd.org Received: from houston.matchlogic.com (houston.matchlogic.com [205.216.147.127]) by hub.freebsd.org (Postfix) with ESMTP id 61DC514D5D for ; Sun, 23 Jan 2000 17:47:19 -0800 (PST) (envelope-from crandall@matchlogic.com) Received: by houston.matchlogic.com with Internet Mail Service (5.5.2650.21) id ; Sun, 23 Jan 2000 18:47:07 -0700 Message-ID: <64003B21ECCAD11185C500805F31EC0304D97797@houston.matchlogic.com> From: Charles Randall To: freebsd-questions@FreeBSD.ORG Subject: RE: UNIX search n replace Date: Sun, 23 Jan 2000 18:47:06 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG From: Greg Lehey [mailto:grog@lemis.com] |> Charles Randall wrote: |>> Grab a Perl manual and build something along the lines of, |>> |>>> perl -i.bak -pe 's/word1/word2/g;' | |Not quite the generic UNIX way. Uh, whatever. These days, Perl is a standard Unix tool. |A better approach to the original question would be: | | for i in *.c *.h; do | sed <$i 's/word1/word2/g' >$i.bak; | mv $i.bak $i; | done IMHO, the Perl one-liner is concise and practical. To be perfectly clear... this one-liner is equivalent to Greg's shell snippet, % perl -i.bak -pe 's/word1/word2/g;' *.[ch] Seeing more than one way to accomplish the same task is probably the best way to learn. To each his own, Charles To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message