When you are using sed
on OS X and when you want to change file in-place using -i
flag, then you need to specify the extension for saving backups of that file.
Check out man sed
section about -i
flag:
-i extension
Edit files in-place, saving backups with the specified extension. If a zero-length extension is
given, no backup will be saved. It is not recommended to give a zero-length extension when in-
place editing files, as you risk corruption or partial content in situations where disk space is
exhausted, etc.
So, the correct command would be:
sed -i "bak" "s/\\\//g" myFile
And if you do not want to make backup file, you could just write like this:
sed -i "" "s/\\\//g" myFile
If you want to make your script platform independent you can check the $OSTYPE
environment variable for that:
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i "" "s/\\\//g" myFile
else
sed -i "s/\\\//g" myFile
fi