* (e)grep "remove lines with only numbers"
@ 2004-07-08 7:49 lists
2004-07-08 8:56 ` zavandi
2004-07-08 11:08 ` M. B. Heath
0 siblings, 2 replies; 7+ messages in thread
From: lists @ 2004-07-08 7:49 UTC (permalink / raw)
To: Linux-Admin
HOwdy --
This is seem like it should be a simple task for grep.
I have a file that looks like this:
\section{Chapter 1}
1
One fish two fish
2 3
Red fish blue fish
What I want to do i remove the line that have numbers on them and nothing else?
TIA,
David
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: (e)grep "remove lines with only numbers"
2004-07-08 7:49 (e)grep "remove lines with only numbers" lists
@ 2004-07-08 8:56 ` zavandi
2004-07-08 10:03 ` A. R. Vener
2004-07-08 11:08 ` M. B. Heath
1 sibling, 1 reply; 7+ messages in thread
From: zavandi @ 2004-07-08 8:56 UTC (permalink / raw)
To: lists; +Cc: Linux-Admin
lists@lastisfirst.com wrote:
> This is seem like it should be a simple task for grep.
> I have a file that looks like this:
>
>
>
> \section{Chapter 1}
>
> 1
> One fish two fish
> 2 3
>
> Red fish blue fish
>
>
> What I want to do i remove the line that have numbers on them and nothing else?
Maybe something like:
egrep -v '^[0-9 ]*[0-9][0-9 ]*$'
?
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: (e)grep "remove lines with only numbers"
2004-07-08 8:56 ` zavandi
@ 2004-07-08 10:03 ` A. R. Vener
0 siblings, 0 replies; 7+ messages in thread
From: A. R. Vener @ 2004-07-08 10:03 UTC (permalink / raw)
To: Linux-Admin
Try:
grep -v "^[0-9]*$" file > newfile
> > This is seem like it should be a simple task for grep.
> > I have a file that looks like this:
> >
> >
> >
> > \section{Chapter 1}
> >
> > 1
> > One fish two fish
> > 2 3
> >
> > Red fish blue fish
> >
> >
> > What I want to do i remove the line that have numbers on them and nothing else?
Rudy Vener
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: (e)grep "remove lines with only numbers"
2004-07-08 7:49 (e)grep "remove lines with only numbers" lists
2004-07-08 8:56 ` zavandi
@ 2004-07-08 11:08 ` M. B. Heath
2004-07-08 15:24 ` zavandi
1 sibling, 1 reply; 7+ messages in thread
From: M. B. Heath @ 2004-07-08 11:08 UTC (permalink / raw)
To: lists; +Cc: Linux-Admin
On Thu, 8 Jul 2004 lists@lastisfirst.com wrote:
> HOwdy --
>
> This is seem like it should be a simple task for grep.
> I have a file that looks like this:
>
> \section{Chapter 1}
>
> 1
> One fish two fish
> 2 3
>
> Red fish blue fish
>
>
> What I want to do i remove the line that have numbers on them and
> nothing else?
Assuming that you mean you want to remove the lines that have only numbers
on them, and leave the line that has both numbers and letters, something
like this should work...
egrep -v '^[0-9 ][0-9 ]*$'
In other words, match lines beginning with a number or space, followed by
0 or more numbers or spaces.
This will leave the line with "Chapter 1" in it. If you waant to remove
that too, then all you would need is
egrep -v '[0-9]'
I would strongly recommend getting a copy of "Mastering Regular
Expressions" by Jeffrey E. F. Fredl, and/or checking out
http://sitescooper.org/tao_regexps.html if you want a really good workout
in regular expression creation.
Malcolm
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: (e)grep "remove lines with only numbers"
2004-07-08 11:08 ` M. B. Heath
@ 2004-07-08 15:24 ` zavandi
2004-07-08 16:01 ` Malcolm Heath
0 siblings, 1 reply; 7+ messages in thread
From: zavandi @ 2004-07-08 15:24 UTC (permalink / raw)
To: M. B. Heath, linux-admin
M. B. Heath wrote:
> egrep -v '^[0-9 ][0-9 ]*$'
Maybe, but that would also remove the lines containing only spaces...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: (e)grep "remove lines with only numbers"
2004-07-08 15:24 ` zavandi
@ 2004-07-08 16:01 ` Malcolm Heath
2004-07-08 18:19 ` lists
0 siblings, 1 reply; 7+ messages in thread
From: Malcolm Heath @ 2004-07-08 16:01 UTC (permalink / raw)
To: zavandi; +Cc: linux-admin
This was a quickly thrown together expression to deal with the input
the poster had specified, which didn't have any lines of only spaces.
But you definitely have a point. The one you posted is much better
than mine.
Malcolm
On Jul 8, 2004, at 8:24 AM, zavandi wrote:
> M. B. Heath wrote:
>> egrep -v '^[0-9 ][0-9 ]*$'
>
> Maybe, but that would also remove the lines containing only spaces...
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: (e)grep "remove lines with only numbers"
2004-07-08 16:01 ` Malcolm Heath
@ 2004-07-08 18:19 ` lists
0 siblings, 0 replies; 7+ messages in thread
From: lists @ 2004-07-08 18:19 UTC (permalink / raw)
To: Malcolm Heath; +Cc: zavandi, linux-admin
Quoting Malcolm Heath <malcolm@indeterminate.net>:
> This was a quickly thrown together expression to deal with the input
> the poster had specified, which didn't have any lines of only spaces.
>
That's to all of you for you suggestions.It did the trick.
Malcolm,
Thanks for the link to the regrex tutorial, I have a look at it.
The book your referring to is from O'Reilly, I actually had that at one point a
couple of years ago.
Thanks again,
David
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-07-08 18:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-08 7:49 (e)grep "remove lines with only numbers" lists
2004-07-08 8:56 ` zavandi
2004-07-08 10:03 ` A. R. Vener
2004-07-08 11:08 ` M. B. Heath
2004-07-08 15:24 ` zavandi
2004-07-08 16:01 ` Malcolm Heath
2004-07-08 18:19 ` lists
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).