![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Display Modes | Rate This Thread |
|
|