sed: 1: “x.log”: extra characters at the end of x command
Writing by shivdev on Tuesday, 26 of May , 2015 at 5:25 am
While using sed in-place edit through sed -i on MacOS X, you will run into the following error.
This will ERROR out
mac:tmp shivdev$ sed -i “s/Apr/May/g” x.log
sed: 1: “x.log”: extra characters at the end of x command
Using an empty extension as shown below Will PASS
mac:tmp shivdev$ sed -i “” “s/Apr/May/g” x.log
The reason that it works fine on Ubuntu but not on MacOS is that it uses a BSD sed (not GNU sed like Ubuntu)
-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 situ-
ations where disk space is exhausted, etc.
Leave a comment
- Add this post to
- Del.icio.us -
- Digg -
- -
- Tweet -
-
-