Hi,
The scenerio is that I want to replace a text in one particular line of a file. But when I am using the sed it's replacing all the occurences of that text.
Like the file is:
>cat test
DNGGF10 :None :Test
DNGGF11 :ABC :Test1
DNGGF12 :None :Test2
DNGGF13 :None : Test3
I have written the following code for this:-
>cat script
name=$1
sed "s/`grep DNGGF10 test|cut -d ':' -f2`/$1/" test >test.chk
But while executing the code as ./script yogi then I am getting O/p in test.chk as:
>cat test.chk
DNGGF10 :Yogi:Test
DNGGF11 :ABC :Test1
DNGGF12 :yogi:Test2
DNGGF13 :Yogi: Test3
But i want to replce second field only for that line which contains DNGGF1O i.e the 1st line.Also space total sapce in second field should also not get altered.
Kindly shed some light on it.
Thanks-
Yogi