Date: Mon, 10 May 2010 04:42:01 +0000 From: "b. f." <bf1783@googlemail.com> To: freebsd-questions@FreeBSD.org Cc: Fbsd1 <fbsd1@a1poweruser.com> Subject: Re: how to find literal in file and them delete that line Message-ID: <AANLkTilGhCHDQvKa3oFWAzq_0Kh_aHRORhQfcteFn-kB@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
>Alberto Mijares wrote: >> On Sun, May 9, 2010 at 11:08 PM, Fbsd1 <fbsd1 at a1poweruser.com> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTilGhCHDQvKa3oFWAzq_0Kh_aHRORhQfcteFn-kB>