I have the following sed -e 's/<em\:update.*//g' install.rdf > install.rdf in a bash script, and it works on command line, but in the bash script install.rdf ends up a blank file.
When I run sed -e 's/<em\:update.*//g' install.rdf > install.rdf command line, then 2 lines are stripped out of the file.
Any idea why sed -e 's/<em\:update.*//g' install.rdf > install.rdf is not working in the bash script?
Try this:
When you redirect output to a file in truncate mode, the file is truncated first, before it’s read. Thus, the result is an empty file. Using
sed -iavoids this.Portable (and hopefully not too insecure) solution:
🙂