From owner-freebsd-questions@FreeBSD.ORG Wed Jan 11 20:47:31 2006 Return-Path: X-Original-To: questions@freebsd.org 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 C82F016A41F for ; Wed, 11 Jan 2006 20:47:31 +0000 (GMT) (envelope-from jerrymc@clunix.cl.msu.edu) Received: from clunix.cl.msu.edu (clunix.cl.msu.edu [35.9.2.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 34BAA43D6B for ; Wed, 11 Jan 2006 20:47:25 +0000 (GMT) (envelope-from jerrymc@clunix.cl.msu.edu) Received: from clunix.cl.msu.edu (localhost [127.0.0.1]) by clunix.cl.msu.edu (8.12.10+Sun/8.12.2) with ESMTP id k0BKlPiU019515; Wed, 11 Jan 2006 15:47:25 -0500 (EST) Received: (from jerrymc@localhost) by clunix.cl.msu.edu (8.12.10+Sun/8.12.2/Submit) id k0BKlObZ019514; Wed, 11 Jan 2006 15:47:24 -0500 (EST) From: Jerry McAllister Message-Id: <200601112047.k0BKlObZ019514@clunix.cl.msu.edu> To: vaaf@broadpark.no (Kristian Vaaf) Date: Wed, 11 Jan 2006 15:47:24 -0500 (EST) In-Reply-To: X-Mailer: ELM [version 2.5 PL7] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: questions@freebsd.org Subject: Re: My script to replace strings in ASCII files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2006 20:47:31 -0000 > > > Hello! > > Just curious, what do I need to do to be able to execute this script like: > > $ text-replace old_string new_string Check out tr(1). It does a good job of it with very simple rules. ////jerry > > I find it a bit inconvenient having to edit the script for every thing I need to replace. > > Thanks, > Kristian > > #!/usr/local/bin/bash > # > # Replace old with new inside all text files. > # $URBAN: text-replace.sh,v 1.0 2005/10/24 15:09:05 vaaf Exp $ > # > > for file in `find . -type f ! -name ".*"`; do > > if [ "`file -b "$file" | grep text`" != "" ]; then > > sed -i '' "s/old/new/g" "$file" > > echo "$file: Done" > > fi > > done > > > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >