The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 10-21-2008
wempy's Avatar
wempy wempy is offline
Registered User
  
 

Join Date: Jun 2006
Location: Harpenden, UK
Posts: 208
you need to add some quantifiers and limiters in there

Code:
sed 's/.*\([0-9]\{3\}-[0-9]\{4\}-[0-9A-Z]\{3\}\).*/\1/'

which will look for anything followed by \( exactly 3 digits followed by a - followed by exactly 4 digits, followed by a - followed by a combination of 3 letters and/or digits \) followed by anything and replace it all with the part above in \( .. \)

Last edited by wempy; 10-21-2008 at 11:38 AM.. Reason: for clarity