From owner-freebsd-questions@FreeBSD.ORG Thu Oct 14 08:02:26 2004 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 AD66716A4CE for ; Thu, 14 Oct 2004 08:02:26 +0000 (GMT) Received: from web51601.mail.yahoo.com (web51601.mail.yahoo.com [206.190.38.206]) by mx1.FreeBSD.org (Postfix) with SMTP id 1A8CA43D1D for ; Thu, 14 Oct 2004 08:02:24 +0000 (GMT) (envelope-from jay2xra@yahoo.com) Message-ID: <20041014080223.26811.qmail@web51601.mail.yahoo.com> Received: from [202.90.128.21] by web51601.mail.yahoo.com via HTTP; Thu, 14 Oct 2004 01:02:23 PDT Date: Thu, 14 Oct 2004 01:02:23 -0700 (PDT) From: Mark Jayson Alvarez To: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: commenting/uncommenting a particular line in place 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: Thu, 14 Oct 2004 08:02:26 -0000 Good Day, I'm looking for a command combinations (not and editor) that would uncomment or comment a line in any configuration file such as inetd.conf with just one single stroke. For example here's the line in inetd.conf that will enable ftpd: #ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l sure, I can extract that particular line using cat and grep, but I'm not quit sure how am I going to edit it. If it is commented by default, I can just say: cat /etc/inetd.conf |grep #ftp |grep -v 6 |sed -e 's/#//' to extract and edit that particular line and then pipe the output to 'tee -a' to be able to append it at the bottom of inetd.conf. But what if it's already uncommented? I know a little bit of perl and I'm thinking of reading the entire inetd.conf line by line and then when I hit that certain line, insert a # in front of it, all being done while writing it to another file and then replacing the original inetd.conf after everything has been written. Do you have any idea how it is done without using perl, perhaps with command combinations etc.. Thanks for the time. _______________________________ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com