From owner-freebsd-questions Mon Dec 2 7:36:27 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 175BC37B401 for ; Mon, 2 Dec 2002 07:36:26 -0800 (PST) Received: from grillolja.cs.umu.se (grillolja.cs.umu.se [130.239.40.17]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2914043EB2 for ; Mon, 2 Dec 2002 07:36:25 -0800 (PST) (envelope-from tdv94ped@cs.umu.se) Received: from localhost (localhost [127.0.0.1]) by amavisd-new (Postfix) with ESMTP id DD62EA008; Mon, 2 Dec 2002 16:36:23 +0100 (MET) Received: from kvist.cs.umu.se (kvist.cs.umu.se [130.239.40.192]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by grillolja.cs.umu.se (Postfix) with ESMTP id 713C59FE2; Mon, 2 Dec 2002 16:36:21 +0100 (MET) Date: Mon, 2 Dec 2002 16:36:21 +0100 (MET) From: Paul Everlund To: =?iso-8859-9?Q?Malik_B=FClent?= Cc: questions@freebsd.org Subject: Re: is there a "replace command" ? In-Reply-To: <012401c299fc$ed221f80$dc96eed5@ymmaslak> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new amavisd-new-20020630 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 Mon, 2 Dec 2002, [iso-8859-9] 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 ? Unfortunately I deleted your other mail, asking how to remove lines containing some text in a file, but this might be one of many solutions: # perl -e 'open(FD,") { if(!($_ =~ /texttolookfor/)) { print "$_"; }} close(FD);' > file.tmp This has not been tested, so use it at your own risk. :-) Best regards, Paul To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message