From owner-freebsd-questions@FreeBSD.ORG Thu Jul 10 12:32:42 2003 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 E6BEA37B401 for ; Thu, 10 Jul 2003 12:32:42 -0700 (PDT) Received: from franklin-belle.com (adsl-65-68-247-73.dsl.crchtx.swbell.net [65.68.247.73]) by mx1.FreeBSD.org (Postfix) with ESMTP id F3D0F43F3F for ; Thu, 10 Jul 2003 12:32:41 -0700 (PDT) (envelope-from jackstone@sage-one.net) Received: from sagea (sagea.sage-american [10.0.0.3]) by franklin-belle.com (8.12.8p1/8.12.8) with SMTP id h6AJWHrv031248; Thu, 10 Jul 2003 14:32:17 -0500 (CDT) (envelope-from jackstone@sage-one.net) Message-Id: <3.0.5.32.20030710143215.013626b8@sage-one.net> X-Sender: jackstone@sage-one.net X-Mailer: QUALCOMM Windows Eudora Pro Version 3.0.5 (32) Date: Thu, 10 Jul 2003 14:32:15 -0500 To: Dan Nelson From: "Jack L. Stone" In-Reply-To: <20030710182658.GC49845@dan.emsphone.com> References: <3.0.5.32.20030710123009.0135fe88@sage-one.net> <3.0.5.32.20030710123009.0135fe88@sage-one.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, hits=-2.0 required=4.5 tests=AWL,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.54-fbelle.rules_v1 X-Spam-Checker-Version: SpamAssassin 2.54-fbelle.rules_v1 (1.174.2.17-2003-05-11-exp) cc: freebsd-questions@freebsd.org Subject: Re: Replacing string in multiple files 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: Thu, 10 Jul 2003 19:32:43 -0000 At 01:26 PM 7.10.2003 -0500, Dan Nelson wrote: >In the last episode (Jul 10), Jack L. Stone said: >> Am running FBSD.4.8-R >> >> At times, I need to replace an existing string in a file that has the same >> name in all ~user accounts and know there must be a short script to do that >> and suspect it involves sed(1). However, had no luck getting it to work >> yet. Basically want to do this: >> >> - find same files in all ~users by same name "~users/myfile" >> - replace this ${string} with this ${string} in the above files >> - report list of above files modified successfully > >If all your users share a common hierarchy: > >sed -i.bak -e s/oldstring/newstring/ /home/*/myfile > >You'll need to be running FreeBSD 4.7 or newer for sed -i to work. Not >sure how to get a list of changed files, though. Maybe just do a grep >beforehand? > >-- > Dan Nelson > dnelson@allantgroup.com > Thanks, Dan.... knew it would be simple. Can probably grep and/or diff for the changes.... Best regards, Jack L. Stone, Administrator SageOne Net http://www.sage-one.net jackstone@sage-one.net