Reputation: 8259
I am using sed
command in a shell script to edit & replace some file content of an xml file in a osx(unix) environment. Is there some way I can avoid sed creating the temporary files with -e
? I am doing the following in my script to edit a file with sed.
sed -i -e 's/abc/xyz/g' /PathTo/MyEditableFile.xml
Above sed
command works great but creates an extra file as /PathTo/MyEditableFile.xml-e
How can I avoid creation of the the extra file with -e
there ?
I tried some options like setting a temporary folder path to sed
so that it creates the temporary file in /tmp/
. Like so:
sed -i -e 's/abc/xyz/g' /PathTo/MyEditableFile.xml >/tmp
But doesnt seem to work
Upvotes: 1
Views: 1236
Reputation: 42107
As you are editing the file in place (-i
), OS X sed
requires a mandatory backup filename.
You can use -i ""
to get around this:
sed -i "" -e 's/abc/xyz/g' /PathTo/MyEditableFile.xml
Upvotes: 4