From owner-freebsd-questions Mon Dec 2 4:41:37 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 254DA37B401 for ; Mon, 2 Dec 2002 04:41:36 -0800 (PST) Received: from ip68-14-62-49.no.no.cox.net (ip68-14-62-49.no.no.cox.net [68.14.62.49]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8698343EA9 for ; Mon, 2 Dec 2002 04:41:35 -0800 (PST) (envelope-from conrads@cox.net) Received: from ip68-14-62-49.no.no.cox.net (localhost [127.0.0.1]) by ip68-14-62-49.no.no.cox.net (8.12.6/8.12.6) with ESMTP id gB2CfYsP065316; Mon, 2 Dec 2002 06:41:35 -0600 (CST) (envelope-from conrads@ip68-14-62-49.no.no.cox.net) Received: (from conrads@localhost) by ip68-14-62-49.no.no.cox.net (8.12.6/8.12.6/Submit) id gB2CfTi7065315; Mon, 2 Dec 2002 06:41:29 -0600 (CST) (envelope-from conrads) Message-ID: X-Mailer: XFMail 1.5.3 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <012401c299fc$ed221f80$dc96eed5@ymmaslak> Date: Mon, 02 Dec 2002 06:41:29 -0600 (CST) Reply-To: conrads@cox.net Organization: A Rag-Tag Band of Drug-crazed Hippies From: Conrad Sabatier To: =?iso-8859-9?Q?Malik_B=FClent?= Subject: Re: is there a "replace command" ? Cc: questions@FreeBSD.ORG 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 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: sed -i -e 's/^touch /rm /' infile That were a easy one. :-) -- Conrad Sabatier To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message