doubt in sed cmd
+8
akalya
jeeva
Mahee
Maithreyi
preethika subramanian
jennyinhere
anand
Preethi
12 posters
Page 2 of 2 • 1, 2
Re: doubt in sed cmd
ya ya.. i know.. by mistake i hav sent the same.... i had the same doubt wat he had... now its fine.. it works
deepika- Posts : 3
Points : 3
Join date : 2010-03-04
Age : 36
Location : chennai
Re: doubt in sed cmd
wats the dfference bet sed 's/lamb/ham/g' bbbb.txt and 's/lamb/ham/' bbbb.txt
[335848@oracleclient ~]$ cat>bbbb.txt
mlamb lambd
ddss
lamb lamb
ggg lambg
[335848@oracleclient ~]$ sed 's/lamb/ham/' bbbb.txt
mham lambd
ddss
ham lamb
ggg hamg
[335848@oracleclient ~]$ sed 's/lamb/ham/g' bbbb.txt
mham hamd
ddss
ham ham
ggg hamg
i didnt get the logic
[335848@oracleclient ~]$ cat>bbbb.txt
mlamb lambd
ddss
lamb lamb
ggg lambg
[335848@oracleclient ~]$ sed 's/lamb/ham/' bbbb.txt
mham lambd
ddss
ham lamb
ggg hamg
[335848@oracleclient ~]$ sed 's/lamb/ham/g' bbbb.txt
mham hamd
ddss
ham ham
ggg hamg
i didnt get the logic
lalitha- Posts : 14
Points : 16
Join date : 2010-03-08
Re: doubt in sed cmd
sed 's/lamb/ham/g' bbbb.txt
In dis case g means global, so it replaces the word lamb where ever it finds...
sed 's/lamb/ham/' bbbb.txt
but here it replaces lamb oly on the first occurence in a line..
In dis case g means global, so it replaces the word lamb where ever it finds...
sed 's/lamb/ham/' bbbb.txt
but here it replaces lamb oly on the first occurence in a line..
deepika- Posts : 3
Points : 3
Join date : 2010-03-04
Age : 36
Location : chennai
Re: doubt in sed cmd
sed 's/lamb/ham/g' bbbb.txt - g stands for global replacement.It replaces all the lamb's occuring in a particular line with ham.
sed 's/lamb/ham/' bbbb.txt
whereas this replaces only the first occurence of lamb in the line with ham.Hence the difference in output!
sed 's/lamb/ham/' bbbb.txt
whereas this replaces only the first occurence of lamb in the line with ham.Hence the difference in output!
Maithreyi- Posts : 76
Points : 142
Join date : 2010-03-03
Age : 36
Location : Haldia
Page 2 of 2 • 1, 2
Permissions in this forum:
You cannot reply to topics in this forum
|
|