From owner-freebsd-questions@FreeBSD.ORG Thu Oct 14 22:22:40 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 D469F16A4CE for ; Thu, 14 Oct 2004 22:22:40 +0000 (GMT) Received: from smtp1.utdallas.edu (smtp1.utdallas.edu [129.110.10.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id AABA343D41 for ; Thu, 14 Oct 2004 22:22:40 +0000 (GMT) (envelope-from pauls@utdallas.edu) Received: from utd49554 (utd49554.utdallas.edu [129.110.3.85]) by smtp1.utdallas.edu (Postfix) with ESMTP id 973B3388DF2; Thu, 14 Oct 2004 17:16:10 -0500 (CDT) Date: Thu, 14 Oct 2004 17:16:24 -0500 From: Paul Schmehl To: Mark Jayson Alvarez , freebsd-questions@freebsd.org Message-ID: In-Reply-To: <20041014080223.26811.qmail@web51601.mail.yahoo.com> References: <20041014080223.26811.qmail@web51601.mail.yahoo.com> X-Mailer: Mulberry/3.1.6 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: Re: commenting/uncommenting a particular line in place X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Paul Schmehl List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Oct 2004 22:22:40 -0000 --On Thursday, October 14, 2004 01:02:23 AM -0700 Mark Jayson Alvarez wrote: > 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? What's wrong with what you've already got? cat /etc/inetd.conf | grep -v "#" | grep ftp | grep -v 6 | sed -e 's//#/' Paul Schmehl (pauls@utdallas.edu) Adjunct Information Security Officer The University of Texas at Dallas AVIEN Founding Member http://www.utdallas.edu