Unix C++
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Answer for this sed question ??

+2
Christopher
anand
6 posters

Page 2 of 2 Previous  1, 2

Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by Christopher Tue Mar 09, 2010 7:09 pm

hey.. read my post completely.. am not giving any solution.. very confused... confused confused confused
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by Christopher Tue Mar 09, 2010 7:22 pm

hey.. finally got the answer. cheers cheers it search for pattern with 2 characters(one from "father" and one from "baby").

in ur example, u dont have any pattern like that. but look at my first example. it contains "table". t from "father" a from "baby" or a from "father" b from "baby".
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by akalya Tue Mar 09, 2010 7:24 pm

hey guess patterns are taken from both first and second keywords specified in brackets...
in my previous post
ciTe and mAke -->TAble
faTher and bAby-->TAble
faTher and Taxi-->boTTle
faTher and tAxi-->TAble

does it make sense

akalya

Posts : 70
Points : 86
Join date : 2010-03-04

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by akalya Tue Mar 09, 2010 7:25 pm

yup...Smile

akalya

Posts : 70
Points : 86
Join date : 2010-03-04

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by Christopher Tue Mar 09, 2010 7:27 pm

one more thing, 2 characters need not be consecutive. one from first string and one from second string. tats it. it can be in any order.


Sorry.. characters need to be consecutive.


Last edited by Christopher on Tue Mar 09, 2010 8:45 pm; edited 2 times in total (Reason for editing : took wrong example)
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by Mahee Tue Mar 09, 2010 7:33 pm

Guys I didn't get your point..
So can you explain that using the following example,??
[335786@oracleclient ~]$ cat text
father pink powder
pink box table
colour colour colour
jottle jaby pink
father pink hello
pink pink lingavelu

[335786@oracleclient ~]$ sed '/[father][jottle]/s/pink/blue/g' text
father blue powder
pink box table
colour colour colour
jottle jaby blue
father blue hello
blue blue lingavelu

The Last line especially.....
Mahee
Mahee

Posts : 29
Points : 233
Join date : 2010-03-03
Location : Haldia

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by akalya Tue Mar 09, 2010 7:47 pm

@christopher
i can't get watever u say....
but guess consecutive things is considered

[335802@oracleclient ~]$ sed '/[cite][owle]/s/pink/blue/g' 2.txt
father pink powder
pink box table...........///DOESN'T REPLACE THOU ciTe and owLe -->TabLe
colour colour colour
blue bottle baby
pink father baby
pink pink pink


[335802@oracleclient ~]$ sed '/[cite][owla]/s/pink/blue/g' 2.txt
father pink powder
blue box table ................ ///here it is replaced ciTe and owlA-->TAble
colour colour colour
blue bottle baby
pink father baby
pink pink pink


@ mahee


father pink powder
pink box table
colour colour colour
jottle jaby pink
father pink hello
pink pink lingavelu.........////here E from fathEr and L from jottLe form a pattern which is matched to EL in lingavELu
so pink is replaced with blue...

akalya

Posts : 70
Points : 86
Join date : 2010-03-04

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by Christopher Tue Mar 09, 2010 8:46 pm

i agree with u. characters need to be consecutive.
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by Mahee Wed Mar 10, 2010 12:55 pm

Is the Formation of Pattern is by respective index of the strings, or all the possible combinations are considered as search patterns???
Mahee
Mahee

Posts : 29
Points : 233
Join date : 2010-03-03
Location : Haldia

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by Christopher Wed Mar 10, 2010 1:02 pm

all combinations are considered as search pattern. only condition is one character from 1st string(it can be any character, irrespective of index position) and the next character should be from 2nd string.
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by Mahee Wed Mar 10, 2010 1:07 pm

thx
Mahee
Mahee

Posts : 29
Points : 233
Join date : 2010-03-03
Location : Haldia

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by anand Wed Mar 10, 2010 1:22 pm

thanks guys..

but is there a way to match multiple patterns without using "sed -e"????
anand
anand

Posts : 55
Points : 70
Join date : 2010-02-26
Age : 36

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by Christopher Wed Mar 10, 2010 1:24 pm

i don think so... tatsy we have '-e' switch... but its my assumption.. not sure... Idea
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by Saradha Kannan Wed Mar 10, 2010 4:23 pm

cat 1.txt
The baby is pink.
baby wears pink dress.
Pink is its fav color.
father gets baby pink dress.
baby father cos he gets pink dress.
father s happy with pink.
hey elr is as good as pink.

sed '/[father][baby]/s/pink/blue/g' 1.txt
The baby is blue.
baby wears blue dress.
Pink is its fav color.
father gets baby blue dress.
baby father cos he gets blue dress.
father s happy with blue.
hey elr is as good as blue.

WHAT ABT THE LAST LINE????
It is replacing the pink with blue???? the pattern 'elr' has no consec alphabets plus both from 'father' only!!
Am confused!!!

Saradha Kannan

Posts : 25
Points : 25
Join date : 2010-03-04

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by akalya Wed Mar 10, 2010 4:36 pm

@saradha

what abt ey in hey
e--->father
y---->baby

akalya

Posts : 70
Points : 86
Join date : 2010-03-04

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by Saradha Kannan Wed Mar 10, 2010 5:58 pm

oh Smile thanks Smile

Saradha Kannan

Posts : 25
Points : 25
Join date : 2010-03-04

Back to top Go down

Answer for this sed question  ?? - Page 2 Empty Re: Answer for this sed question ??

Post by Sponsored content


Sponsored content


Back to top Go down

Page 2 of 2 Previous  1, 2

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum