From owner-freebsd-questions@FreeBSD.ORG Fri May 13 09:41:04 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 3CF9416A4CE for ; Fri, 13 May 2005 09:41:04 +0000 (GMT) Received: from zero.ramb.com.ua (zero.ramb.com.ua [62.149.0.90]) by mx1.FreeBSD.org (Postfix) with ESMTP id 59B0943D2D for ; Fri, 13 May 2005 09:41:03 +0000 (GMT) (envelope-from fenix@ramb.com.ua) Received: from sirius (ip.82.144.202.143.stat-9.volia.net [82.144.202.143]) by zero.ramb.com.ua (8.13.3/8.13.3) with ESMTP id j4DCjg7c019000; Fri, 13 May 2005 12:45:49 GMT (envelope-from fenix@ramb.com.ua) From: "Sergey S. Ropchan" To: questions@freebsd.org, Fafa Hafiz Krantz In-Reply-To: <20050513092905.D003E4BEAD@ws1-1.us4.outblaze.com> References: <20050513092905.D003E4BEAD@ws1-1.us4.outblaze.com> Content-Type: text/plain Date: Fri, 13 May 2005 12:40:53 +0300 Message-Id: <1115977253.28135.17.camel@sirius> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.80/875/Tue May 10 11:27:59 2005 clamav-milter version 0.80j on zero.ramb.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=6.3 tests=none autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on zero.ramb.com.ua Subject: Re: How to replace words in all 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: Fri, 13 May 2005 09:41:04 -0000 find / -name '*' -print | xargs grep "lnc0" - gives you all files in your system with lnc0 ... perl -pi.bak -pe 's/lnc0/rl0/' file1 file2 ... fileN - will replace lnc0 - rl0 in all specified files, with backuping of old files in *.bak > Hello! > > I have a bunch of configuration files which all contain the word, > or the reference to, my dysfunctional network interface lnc0. I used > to have this simple script -- to replace a word in all ASCII files > containing it -- with another word. In this case, I need to replace > the string `lnc0' with `rl0' in all my configuration files. And is > it possible having this script tell me what files it modified? > > I promise I'll write it down this time :) > And be generous on handing it back out to the society! > > > -- > > Fafa Hafiz Krantz > Research Designer @ http://www.home.no/barbershop > Enlightened @ http://www.home.no/barbershop/smart/sharon.pdf > > >