Re: (e)grep "remove lines with only numbers"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 8 Jul 2004 lists@xxxxxxxxxxxxxxx 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


-
: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux