Deleting all lines containing numbers | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Deleting all lines containing numbers

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-27-2012
dunryc dunryc is offline
Registered User
 
Join Date: Nov 2007
Last Activity: 13 September 2014, 4:30 PM EDT
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Deleting all lines containing numbers

Hi guys

I have a text file in the following format

Quote:
1410054
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec diam dui,
congue sed tristique eget, pulvinar in enim. Nam tortor odio, rhoncus
sit amet suscipit eget, fringilla non purus. Donec non condimentum neque.
Praesent adipiscing nibh at mauris aliquam non fermentum dolor adipiscing.
Ut dolor mauris, condimentum in dapibus non, convallis vitae quam. Aenean
tincidunt justo at magna congue condimentum. Vestibulum lacus nisl, portt

1410187
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec diam dui,
congue sed tristique eget, pulvinar in enim. Nam tortor odio, rhoncus
sit amet suscipit eget, fringilla non purus. Donec non condimentum neque.
Praesent adipiscing nibh at mauris aliquam non fermentum dolor adipiscing.
Ut dolor mauris, condimentum in dapibus non, convallis vitae quam. Aenean
tincidunt justo at magna congue condimentum. Vestibulum lacus nisl, portt
what i would like ot do is iterate through the file deleting the lines containing only numbers. I have googled this and have been unable to find any help ( maybe its my search terms)

so if any one an give me a heads up i would appreciate it

dunryc
Sponsored Links
    #2  
Old 12-27-2012
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 16 September 2014, 5:12 PM EDT
Location: Galactic Empire
Posts: 3,380
Thanks: 234
Thanked 1,204 Times in 1,131 Posts
How about using grep:

Code:
grep '[^0-9]' filename

Sponsored Links
    #3  
Old 12-27-2012
dunryc dunryc is offline
Registered User
 
Join Date: Nov 2007
Last Activity: 13 September 2014, 4:30 PM EDT
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
that works a treat would you know if there is any way of replacing those lines with another string ?

thanks
    #4  
Old 12-27-2012
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 16 September 2014, 5:12 PM EDT
Location: Galactic Empire
Posts: 3,380
Thanks: 234
Thanked 1,204 Times in 1,131 Posts
Assuming numbers are 7 digit length:

Code:
sed 's/[0-9]\{7\}/string/g' filename

Generic approach:

Code:
sed 's/[0-9]\+/string/g' filename

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Deleting lines not starting with numbers with sed drbiloukos Shell Programming and Scripting 4 12-24-2010 06:41 AM
deleting lines in ex drareeg Shell Programming and Scripting 2 11-07-2010 10:42 AM
Deleting particular lines. kashifv Shell Programming and Scripting 13 10-15-2009 05:52 AM
deleting lines ajnabi Shell Programming and Scripting 8 05-02-2003 11:50 AM
deleting lines supercbw Programming 1 05-06-2002 12:53 PM



All times are GMT -4. The time now is 07:30 PM.