osx - sed command with -i option failing on Mac, but works on Linux -
i've used following sed
command search/replace text in linux:
sed -i 's/old_link/new_link/g' *
however, when try on mac os x, get:
"command c expects \ followed text"
i thought mac runs normal bash shell. what's up?
edit:
according @high performance, due mac sed
being of different (bsd) flavor, question therefore how replicate command in bsd sed
?
edit:
here actual example causes this:
sed -i 's/hello/gbye/g' *
if use -i option need provide extension backups.
if have:
file1.txt file2.cfg
the command:
sed -i '.original' 's/old_link/new_link/g' *
create 2 backup files like:
file1.txt.original file2.cfg.original
there no portable way avoid making backup files because impossible find mix of sed commands works on cases:
sed -i -e ...
- not work on os x creates-e
backupssed -i'' -e ...
- not work on os x 10.6 works on 10.9+sed -i '' -e ...
- not working on gnu
Comments
Post a Comment