invalid command code ., despite escaping periods, using sed
If you are on a OS X, this probably has nothing to do with the sed command. On the OSX version of sed
, the -i
option expects an extension
argument so your command is actually parsed as the extension
argument and the file path is interpreted as the command code.
Try adding the -e
argument explicitly and giving ''
as argument to -i
:
find ./ -type f -exec sed -i '' -e "s/192.168.20.1/new.domain.com/" {} \;
See this.
You simply forgot to supply an argument to -i
. Just change -i
to -i ''
.
Of course that means you don't want your files to be backed up; otherwise supply your extension of choice, like -i .bak
.
On OS X nothing helps poor builtin sed to become adequate. The solution is:
brew install gnu-sed
And then use gsed instead of sed, which will just work as expected.