From owner-freebsd-questions Mon Dec 2 5:20:48 2002 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 3E1EB37B401 for ; Mon, 2 Dec 2002 05:20:47 -0800 (PST) Received: from catv-50622a7a.nyircatv.broadband.hu (catv-50622a7a.nyircatv.broadband.hu [80.98.42.122]) by mx1.FreeBSD.org (Postfix) with ESMTP id D53C943EC5 for ; Mon, 2 Dec 2002 05:20:45 -0800 (PST) (envelope-from andrew@kronos.HomeUnix.com) Received: from slave.east.ath.cx (witch@slave.east.ath.cx [10.1.1.1]) by catv-50622a7a.nyircatv.broadband.hu (8.12.6/8.12.6) with ESMTP id gB2DKiqp045315 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Mon, 2 Dec 2002 14:20:44 +0100 (CET) (envelope-from andrew@east.ath.cx) Date: Mon, 2 Dec 2002 14:20:44 +0100 (CET) From: Andrew Prewett Reply-To: Andrew Prewett To: questions@FreeBSD.ORG Subject: Re: is there a "replace command" ? In-Reply-To: Message-ID: <20021202140543.G19865-100000@slave.east.ath.cx> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Today Conrad Sabatier wrote: > > On 02-Dec-2002 Malik Bülent wrote: > > On Freebsd4.x > > I have a file. I want to change some expressions with new ones > > For example a file > > touch /var/qmail/1 > > touch /var/qmail/2 > > touch /var/qmail/3 > > touch /var/qmail/4 > > touch /var/qmail/5 > > touch /var/qmail/6 > > I want to change "touch" with "rm" > > How can i replace a newones in stead of a lot of expressions in a file > > on > > FreeBSD ? > > Which command(s) do i have to use ? > > Recent versions of FreeBSD now have a version of 'sed' that can do these > types of replacements "in place", i.e., without the need for a temporary > file: No. I'm pretty sure, there is a temporary file somewhere. You can't edit a file `in place' really, w/o a need temporary files (or ev. memory mapping the file). With the `-i' flag sed does this for you, ie. no need that you create a temporary file. -andrew > > sed -i -e 's/^touch /rm /' infile > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message