Yes. Use:
sed -i '' "s@line@new@" output_file
On BSD systems (and macOS too), the sed
command's -i
option requires a suffix, which may be attached to the -i
or a separate argument. However, when the suffix is empty, it must be a separate argument. This is different from GNU sed
, where the -i
option takes an optional suffix, but if specified, it must be attached to the -i
option. Scripts portable between the two (BSD and GNU) therefore must be written with an explicit non-empty suffix attached to the -i
option. Note that such scripts may still be unportable to other POSIX systems; the -i
option is not standardized (as you can tell from the divergent behaviour).