(e)grep "remove lines with only numbers"
(e)grep "remove lines with only numbers"
am 08.07.2004 09:49:36 von lists
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
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: (e)grep "remove lines with only numbers"
am 08.07.2004 10:56:15 von zavandi
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 ]*$'
?
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: (e)grep "remove lines with only numbers"
am 08.07.2004 12:03:56 von salt
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
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: (e)grep "remove lines with only numbers"
am 08.07.2004 13:08:33 von Malcolm
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
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: (e)grep "remove lines with only numbers"
am 08.07.2004 17:24:51 von zavandi
M. B. Heath wrote:
> egrep -v '^[0-9 ][0-9 ]*$'
Maybe, but that would also remove the lines containing only spaces...
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: (e)grep "remove lines with only numbers"
am 08.07.2004 18:01:57 von Malcolm Heath
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...
>
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: (e)grep "remove lines with only numbers"
am 08.07.2004 20:19:30 von lists
Quoting Malcolm Heath :
> 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
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html