From owner-freebsd-questions@FreeBSD.ORG Wed Jan 26 16:28:48 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 E0D9A16A4CE for ; Wed, 26 Jan 2005 16:28:48 +0000 (GMT) Received: from ms-smtp-03.tampabay.rr.com (ms-smtp-03-smtplb.tampabay.rr.com [65.32.5.133]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5C35C43D49 for ; Wed, 26 Jan 2005 16:28:48 +0000 (GMT) (envelope-from aj334x5l@tampabay.rr.com) Received: from moe.howard (6532128hfc43.tampabay.rr.com [65.32.128.43]) j0QGSjkv022679 for ; Wed, 26 Jan 2005 11:28:45 -0500 (EST) Received: from moe.howard (localhost.howard [127.0.0.1]) by moe.howard (8.13.1/8.13.1) with ESMTP id j0QGUrrH007512 for ; Wed, 26 Jan 2005 11:30:53 -0500 (EST) (envelope-from aj334x5l@tampabay.rr.com) Received: (from walter@localhost) by moe.howard (8.13.1/8.13.1/Submit) id j0QGUrot007511 for freebsd-questions@freebsd.org; Wed, 26 Jan 2005 11:30:53 -0500 (EST) (envelope-from aj334x5l@tampabay.rr.com) X-Authentication-Warning: moe.howard: walter set sender to aj334x5l@tampabay.rr.com using -f Date: Wed, 26 Jan 2005 11:30:53 -0500 From: Al Johnson To: freebsd-questions@freebsd.org Message-ID: <20050126163053.GA4619@bhunter.net> References: <1878149195.20050126164325@wanadoo.fr> <20050126165505.06d2b3d4.flynn@energyhq.es.eu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050126165505.06d2b3d4.flynn@energyhq.es.eu.org> User-Agent: Mutt/1.4.2.1i X-URL: http://www.landoverbaptist.org X-Virus-Scanned: Symantec AntiVirus Scan Engine 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 16:28:49 -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? Try this. Global search and replace, with backup: # find . -type f | xargs sed -i.bak "s/oldtext/newtext/g" -- Kids can get a free PlayStation 2! http://www.landoverbaptist.org/news0104/ps2.html