From owner-freebsd-questions@FreeBSD.ORG Tue Feb 17 17:03:44 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6364C16A4CE for ; Tue, 17 Feb 2004 17:03:44 -0800 (PST) Received: from sageweb.net (adsl-65-68-247-74.dsl.crchtx.swbell.net [65.68.247.74]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E04B43D1D for ; Tue, 17 Feb 2004 17:03:44 -0800 (PST) (envelope-from webster@sageweb.net) Received: from sageweb.net (localhost.sageweb.net [127.0.0.1]) by sageweb.net (8.12.8p2/8.12.8) with ESMTP id i1I13gdD052790 for ; Tue, 17 Feb 2004 19:03:42 -0600 (CST) (envelope-from webster@sageweb.net) Received: from localhost (webster@localhost) by sageweb.net (8.12.8p2/8.12.8/Submit) with ESMTP id i1I13gMS052787 for ; Tue, 17 Feb 2004 19:03:42 -0600 (CST) (envelope-from webster@sageweb.net) Date: Tue, 17 Feb 2004 19:03:42 -0600 (CST) From: "Jack L. Stone" To: freebsd-questions@freebsd.org Message-ID: <20040217183030.N52674@sageweb.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=1.7 required=4.5 tests=AWL,MDS_Swen_A_0 autolearn=ham version=2.63-sageame.rules_v3.1 X-Spam-Checker-Version: SpamAssassin 2.63-sageame.rules_v3.1 (2004-01-11) on sageweb.net Subject: Using SED in a script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2004 01:03:44 -0000 Sorry if this is somewhat OT, but I *think* I have a simple SED(1) question for those familiar with its use. I am working up a small script that will grep(1) a string like "215 new messages" from a file for use as a variable. I need to then find/replace an "old string" in another file that may say "198 new messages" with the new variable string "215 new messages". So, only the numeric part of the string actually changes. I've looked at the sed approach, but not sure how to apply its use here, or if something else besides sed(1) would be better. This would be the steps: - grep(1) the new string and pipe to sed(1) ..?? - sed(1) to find the old string & replace with the new string in a file. Am I on the right track....?? Tips on the script syntax appreciated. Thanks and.... Happy Trails, Jack L. Stone SageWeb