From owner-freebsd-questions@FreeBSD.ORG Mon May 10 04:42:03 2010 Return-Path: Delivered-To: freebsd-questions@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 38B06106566C for ; Mon, 10 May 2010 04:42:03 +0000 (UTC) (envelope-from bf1783@googlemail.com) Received: from mail-ww0-f54.google.com (mail-ww0-f54.google.com [74.125.82.54]) by mx1.freebsd.org (Postfix) with ESMTP id C46EB8FC15 for ; Mon, 10 May 2010 04:42:02 +0000 (UTC) Received: by wwd20 with SMTP id 20so915782wwd.13 for ; Sun, 09 May 2010 21:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:received:reply-to:date :message-id:subject:from:to:cc:content-type; bh=7wtSJag0/H8UzNN7+tg678YJ+g3DToH3m+CALiYUG1c=; b=gbDsxK7VGEM028fCgsigSAqp1bYT0MEewv0H6ofk80Z23Iw1V+X8zRQ7gS/hMgdGa+ TWIKozlc/UYVcbaQ0C5tgGpl/NXl8/1Uq8QBq5mEmOpQj/RGM9e10h6utNB57Qc+vXZj QBChfO9Ohy+Ns9LKGxO8IKJT7epbv3BPL83OY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:reply-to:date:message-id:subject:from:to:cc :content-type; b=sJL18HhLwx7jbDMFPUdK49YFrvWoApoRfTagGPteNwYICRWaPyH+LowqScdTg/yqDu DL1aBaHh/qMKbZY29qikpR6txvt1gbv4/B5q/M1yYWVQCs2f18GL/mQlwgDCCcMzQKk2 fVF3+T9VGsvYskkNmM1R1E4DMJmzr0BdCZ/5g= MIME-Version: 1.0 Received: by 10.216.87.132 with SMTP id y4mr1550649wee.174.1273466521531; Sun, 09 May 2010 21:42:01 -0700 (PDT) Received: by 10.216.163.21 with HTTP; Sun, 9 May 2010 21:42:01 -0700 (PDT) Date: Mon, 10 May 2010 04:42:01 +0000 Message-ID: From: "b. f." To: freebsd-questions@FreeBSD.org Content-Type: text/plain; charset=ISO-8859-1 Cc: Fbsd1 Subject: Re: how to find literal in file and them delete that line X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: bf1783@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2010 04:42:03 -0000 >Alberto Mijares wrote: >> On Sun, May 9, 2010 at 11:08 PM, Fbsd1 wrote: >>> I want to search every line in the specified file for a literal and if found >>> then delete that line from the file and save the file all from within a sh >>> type of shell script. >> >> >> man(1) sed >> >> Regards >> >That makes no sense to me. >need example It would make sense if you read the sed(1) and re_format(7) manpages. They may be a pain at first, but they are used often and can make your life a lot easier. There are also a lot of tutorial on the web, with many useful examples, e.g.: http://sed.sourceforge.net/grabbag/ He is suggesting that, rather than using sh(1), you should use sed(1), which is typically used for this sort of task, and is also part of the base system, in some fashion like, for example: sed -e '/literal/d' file If you insist on doing this with sh(1), which will probably be less efficient, then you can cobble something together with a 'case' statement, or parameter expansion with substring processing. See the sh(1) manpage. I hope that you are not intending to use this for a FreeBSD Port in the context of your earlier message. As someone else has already told you, ports should _not_ be automatically editing configuration files like rc.conf. Instead they should just indicate what should be added by the user or administrator in a pkg-message. Although you are free to do whatever you want on your own system, if you submit a port that attempts to tamper with such files to FreeBSD Ports, it is likely that that part of your submission will be rejected. b.