Solved

sed 's/\(.*\)...........

Posted on 2002-05-15
5
464 Views
Last Modified: 2013-12-26
Hi
I am trying this
sed 's/\(.*\),\(.*\),\(.*\),\(.*\),\(.*\),\(.*\),\(.*\),\(.*\),\(.*\),\(.*\)/10' <file>

I am not able to get the \10 printed. It prints the \1 instead.

Is this the limitation of SED or of my system.
I am on Tandem OSS.

Or is there a way around to do what i am doing.
Yep i know i can do it with AWK and i am doint it that way.
But i want to do with SED.

Thanks
Ilikenine
0
Comment
Question by:ilikenine
  • 2
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
ecw earned 50 total points
ID: 7011473
limitations of sed, positional replacement only understands a single digiti after the \
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7012059
as ecw said.

and your command also might not work, 'cause .* is greedy.
I suggest:
     awk -F, '{print $10}' file
0
 
LVL 5

Expert Comment

by:ecw
ID: 7012571
good point, even if it could print \10, that'd be nul
0
 
LVL 1

Author Comment

by:ilikenine
ID: 7013800
na but .* goes till the next comma(,) only . It is not that greedy.

so the awk i am using is
awk '{FS=","}{print $10}'

will give points to ECW.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7014521
> It is not that greedy.
Hmm, may depend on sed version: AT&T vs. GNU
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 131
not able to insert into temp table 68 162
method notes when mouse over in eclipse 5 87
MaxSpan challenge 9 96
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question