Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

More than one '-e' in sed on OSX

Tags:

macos

sed

I need to run sed -e 'command' -e 'command' file.txt but I get this error on mac: sed: -e: No such file or directory. Any idea how to fix this?

like image 930
Michael Avatar asked Jan 17 '26 05:01

Michael


1 Answers

Works fine with my sed:

$ echo ax | sed -e 's/a/b/' -e 's/x/y/'
by
$ uname -a
Darwin Equinox.local 12.3.0 Darwin Kernel Version 12.3.0: Sun Jan  6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64
$ which sed
/usr/bin/sed

So the problem must be elsewhere. Judging by your command given in comments, I would try passing the '' argument to the -i option:

$ sed -i '' -e "s/\.$REGIONID\./\./" -e "/\.$NONREGIONID\./d" application.conf

With the caveat described in the man page:

If a zero-length extension is given, no backup will be saved. 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.

like image 128
zoul Avatar answered Jan 19 '26 18:01

zoul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!