The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need a regular expression tony3101 Shell Programming and Scripting 4 06-05-2008 12:13 AM
regular expression subin_bala Shell Programming and Scripting 1 04-29-2008 12:19 AM
Regular Expression matching in PERL Legend986 High Level Programming 7 02-26-2008 01:43 AM
regular expression and awk nickg UNIX for Dummies Questions & Answers 2 08-16-2007 02:23 PM
Regular Expression + Aritmetical Expression Z0mby Shell Programming and Scripting 2 05-21-2002 07:59 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-12-2005
Registered User
 

Join Date: Dec 2005
Posts: 3
Regular expression matching a new line

I have written a script to test some isdn links in my network and I am trying to format the output to be more readable. Each line of the output has a different number of digits as follows...

Sitename , spid1 12345678901234 1234567890 1234567 , spid2 1234567890 1234567890 1234567
Sitename , spid1 12345678901234 1234567890 , spid2 12345678901234 1234567890

I would like to drop any string of either 7 or 10 digits and keep ony the 14 digit strings. I have attemted the following command but it gives me an error "Invalid preceding regular expression"

sed 's/\<[0-9]\>\{7,10\}//g' oldfile > newfile

Can anyone point me in the right direction to format this file? Thank you for the assistance.
Reply With Quote
Forum Sponsor
  #2  
Old 12-12-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Change the word/number boundary indicator to take in more numbers.

Code:
sed -e 's#\<[0-9]\{7\}\>##g' -e 's#\<[0-9]\{10\}\>##g'
or

Code:
sed 's/\<[0-9]\{7,10\}\>//g'

Last edited by vino; 12-12-2005 at 09:47 PM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:30 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0