Possible Duplicate:
Sed command find and replace in file and overwrite file doesnt work, it empties the file!
sed "s/^/getHtmlBody\(\"\/NmConsole\/Reports\/Workspace\/Virtualization\/WrVMwareHostList\/WrVMwareHostList.asp\?sGroupList=1'/g" out.bat | sed "s/$/\';--\");/g" >out.bat
When Bash sees "> out.bat" it truncates the file. The file is now empty, so sed doesn't find the beginnings nor ends of any lines and nothing gets put into out.bat
kojiro's link and codaddict has a nice description plus ways to get around it.