From owner-freebsd-questions@FreeBSD.ORG Wed Jan 26 15:56:49 2005 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 E255A16A4CE for ; Wed, 26 Jan 2005 15:56:49 +0000 (GMT) Received: from clunix.cl.msu.edu (clunix.cl.msu.edu [35.9.2.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4E54843D58 for ; Wed, 26 Jan 2005 15:56:49 +0000 (GMT) (envelope-from jerrymc@clunix.cl.msu.edu) Received: (from jerrymc@localhost) by clunix.cl.msu.edu (8.11.7p1+Sun/8.11.7) id j0QFumN03395; Wed, 26 Jan 2005 10:56:48 -0500 (EST) From: Jerry McAllister Message-Id: <200501261556.j0QFumN03395@clunix.cl.msu.edu> To: freebsd-questions@freebsd.org Date: Wed, 26 Jan 2005 10:56:48 -0500 (EST) In-Reply-To: <1878149195.20050126164325@wanadoo.fr> from "Anthony Atkielski" at Jan 26, 2005 04:43:25 PM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: Jerry McAllister Subject: Re: One-line global string replace in all files with sed (or awk?) 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, 26 Jan 2005 15:56:50 -0000 > > A few years ago, I'm sure I came across a one-line way of replacing > every occurence of one string with another in an entire directory of > files (potentially including all subdirectories as well). I think it > used sed or awk. Now I can't find it. The examples on the Web are all > multiline scripts or programs, but I'm sure I saw a way to do it all on > just one line. > > Can anyone tell me how to do this? Check out tr(1). There are other ways, but for basic stuff, it is easy and fast. I use it often for stripping out the extra CRs from MSDOS files. Something like: tr -d "\r" < dirtydos > cleanunix does the trick. But it will do replaces and pretty much anything. Its syntax is a little different that regular expressions type (maybe a little easier actually) so read the man page. ////jerry > -- > Anthony > > > _______________________________________________ > 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" >