If I dont redirect the output to abc.txt, the command is working fine, even if I append the output to the file, it works. but I want to replace the string in the same file.
OK, so I am that "somebody else"~
You can't redirect your output to the original input file, that would just wipe out the whole file. you can use the i option to replace text in place.
sorry for the trouble. I had tried -i option, but it is not available
D:\>sed -i 's\abc\xyz\g' abc.txt
sed: Unknown option -i
Usage: sed [-n] script [file...]
sed [-nE] [-e script] [-f scriptfile] [file...]
D:\>help sed
sed -- stream editor (non-interactive)
Usage: sed [-En] script [file ...]
sed [-En] [-e script]... [-f scriptfile]... [file ...]
-E use extended regular expressions
-e script add argument "script" to end of script
-n suppress output except from commands in sed script
-f scriptfile add commands in "scriptfile" to script
There's also ed and ex. Just about every single time you see code that uses gnu sed's -i extension, it's something that can be easily done with the ubiquitous, standardized line editors.