4

Possible Duplicate:
Sed command find and replace in file and overwrite file doesnt work, it empties the file!

Ok so I've got this:

sed "s/^/getHtmlBody\(\"\/NmConsole\/Reports\/Workspace\/Virtualization\/WrVMwareHostList\/WrVMwareHostList.asp\?sGroupList=1'/g" out.bat | sed "s/$/\';--\");/g" >out.bat

And as you can see I'm trying to out into out.bat but it isn't working for some reason - nothing gets displayed on the screen but nothing is written to the file.

What am I doing wrong?

Community
  • 1
  • 1

1 Answers1

2

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 an SO asnwer by codaddict has a nice description plus ways to get around it.

drevicko
  • 14,382
  • 15
  • 75
  • 97