From owner-freebsd-questions Mon Dec 2 4:34:51 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 E173137B401 for ; Mon, 2 Dec 2002 04:34:49 -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 83B6F43EC2 for ; Mon, 2 Dec 2002 04:34:48 -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 gB2CYfqp040497 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Mon, 2 Dec 2002 13:34:41 +0100 (CET) (envelope-from andrew@east.ath.cx) Date: Mon, 2 Dec 2002 13:34:41 +0100 (CET) From: Andrew Prewett Reply-To: Andrew Prewett 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: <20021202132745.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 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 ? > 1) sed -e 's,^touch,rm,g' < infile > outfile 2) while read a b; do echo "rm $b"; done < infile > outfile 3) awk '{print "rm "$2}' < infile > outfile -andrew To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message