Quantcast
Viewing all articles
Browse latest Browse all 16

Answer by David Ongaro for sed in-place flag that works both on Mac (BSD) and Linux

The problem is that sed is a stream editor, therefore in-place editing is a non-POSIX extension and everybody may implement it differently. That means for in-place editing you should use ed for best portability. E.g.

ed -s foobar.txt <<<$',s/foo/bar/g\nw'

Also see https://wiki.bash-hackers.org/howto/edit-ed.


Viewing all articles
Browse latest Browse all 16

Trending Articles