Re: how to find literal in file and them delete that line

2010-05-10 Thread Matthew Seaman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/05/2010 04:38:25, 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.
 
 Does anyone have a example they would share with me?

grep -v 'literal'  file  file.new

Cheers,

Matthew

- -- 
Dr Matthew J Seaman MA, D.Phil.   7 Priory Courtyard
  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
  Kent, CT11 9PW
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvnopEACgkQ8Mjk52CukIxlzgCfW1u7k0O1BZ5gCM5emVUfJJGk
80IAn100dDD01WMkTrXXE3NI88Ohd/ZK
=6nDd
-END PGP SIGNATURE-
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


how to find literal in file and them delete that line

2010-05-09 Thread Fbsd1
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.


Does anyone have a example they would share with me?

Thanks.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: how to find literal in file and them delete that line

2010-05-09 Thread Alberto Mijares
On Sun, May 9, 2010 at 11:08 PM, Fbsd1 fb...@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


Alberto Mijares
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: how to find literal in file and them delete that line

2010-05-09 Thread Fbsd1

Alberto Mijares wrote:

On Sun, May 9, 2010 at 11:08 PM, Fbsd1 fb...@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

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: how to find literal in file and them delete that line

2010-05-09 Thread Sahil Tandon
On Mon, 10 May 2010, Fbsd1 wrote:

 Alberto Mijares wrote:
 On Sun, May 9, 2010 at 11:08 PM, Fbsd1 fb...@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
 
 That makes no sense to me.
 need example

What makes no sense?  The sed(1) man page?  Which section in particular
is confusing?  And please, explain the rationale for making your port
automatically edit /etc/rc.conf.

-- 
Sahil Tandon sa...@freebsd.org
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: how to find literal in file and them delete that line

2010-05-09 Thread Fbsd1

Sahil Tandon wrote:

On Mon, 10 May 2010, Fbsd1 wrote:


Alberto Mijares wrote:

On Sun, May 9, 2010 at 11:08 PM, Fbsd1 fb...@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


That makes no sense to me.
need example


What makes no sense?  The sed(1) man page?  Which section in particular
is confusing?  And please, explain the rationale for making your port
automatically edit /etc/rc.conf.


editing /etc/rc.conf was just given as a example for the post.
Yes the whole man sed reads like Greek. For a neophyte programmer I can 
not even begin to comprehend what its saying. That man page needs 
examples of use. You have forgotten that those man pages are for 
reference for people who all ready know how to use it. Its not intended 
for novices. So yes it's useless to me.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: how to find literal in file and them delete that line

2010-05-09 Thread b. f.
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.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: how to find literal in file and them delete that line

2010-05-09 Thread Fbsd1

b. f. wrote:

Alberto Mijares wrote:

snip


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.

Thank you for your kind in-sight. Using sh was again just comments to 
help explain what I needed help with. A list reader replied offline with 
examples and now I have what I needed to proceed.

Thanks to all who replied.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org