Quantcast
Channel: sed in-place flag that works both on Mac (BSD) and Linux - Stack Overflow
Viewing all articles
Browse latest Browse all 16

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

$
0
0

You can use sponge. Sponge is an old unix program, found in moreutils package (both in ubuntu and probably debian, and in homebrew in mac).

It will buffer all the content from the pipe, wait until the pipe is close (probably meaning that the input file is already close) and then overwrite:

From the man page:

Synopsis

sed '...' file | grep '...' | sponge file


Viewing all articles
Browse latest Browse all 16

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>