In order to use a /
in the replacement it can either be escaped with a \
,
or the s
command can use a different delimiter:
sed 's|root|usr/local|g' ...
Additionally the (non-standard) -i
option requires an argument in FreeBSD sed(1)
and, by extension, macOS (OS X) sed(1)
. In this case giving a zero-length argument (-i ''
) will have the same effect as having no argument would for GNU sed(1)
.
However the man-page warns against that usage:
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.
Also, if the extention is not in its own argument then the syntaxes are compatible:
sed -i.bak 's|root|usr/local|g' ...