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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Pick up the return code for every iteration and display the result only once in loop. manas6 Shell Programming and Scripting 1 10-21-2008 08:12 AM
Iteration on line number using perl jyo123.jyothi Shell Programming and Scripting 4 08-08-2008 08:06 PM
Iteration through the results from a unix command deviprasad83 Shell Programming and Scripting 4 06-12-2008 05:04 AM
New iteration of for-loop without incrementing? jeriryan87 Shell Programming and Scripting 0 07-02-2007 03:13 PM
renaming variable between iteration Nicol Shell Programming and Scripting 2 04-06-2005 09:04 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-13-2009
Bubnoff Bubnoff is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 15
sed 'iteration character' question

I'm processing ( trying to anyway ) a file of pipe delimited database output.

Sample record:

Code:
365026 | ocn424525329 | With his lightening-quick hands and feet

The second field in the above data is "ocn424525329". It should be
"424525329" with no trailing or leading spaces. This may be better approached with awk but while I try that I thought I'd ask something that's been bothering me about sed's iteration metacharacter: {n} or {n,m}.

For example, suppose I want to replace this field with the word 'hello' ...

Why can I not match this with:

Code:
sed 's/ocn[0-9]{9}/hello/g' tmp

???

No matter what I try the {n} meta sequence does nothing.

Bub

---------- Post updated at 07:02 PM ---------- Previous update was at 06:55 PM ----------

The following matches:


Code:
sed 's/oc[nm][0-9]\{8,9\} /hello/g' tmp

So I have to escape the braces. When un-escaped, I assume that they are
taken literally?

thanks ~

Bub
Bits Awarded / Charged to Bubnoff for this Post
Date User Comment Amount
10-14-2009 pludi For not relying on us to solve your problem 5,000
 

Bookmarks

Tags
sed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0