inplace-editing

sed command with -i option (in-place editing) works fine on Ubuntu but not Mac [duplicate]

♀尐吖头ヾ 提交于 2019-11-27 04:14:47
问题 This question already has an answer here: sed -i command for in-place editing to work with both GNU sed and BSD/OSX 7 answers I know nothing about Sed but need this command (which works fine on Ubuntu) to work on a Mac OSX: sed -i "/ $domain .*#drupalpro/d" /etc/hosts I'm getting: sed: 1: "/etc/hosts": extra characters at the end of h command 回答1: Ubuntu ships with GNU sed , where the suffix for the -i option is optional. OS X ships with BSD sed , where the suffix is mandatory. Try sed -i ''

I need my sed -i command for in-place editing to work with both GNU sed and BSD/OSX sed

蹲街弑〆低调 提交于 2019-11-26 21:51:02
I've got a makefile (developed for gmake on Linux) that I'm attempting to port to OSX, but it seems like sed doesn't want to cooperate. What I do is use GCC to autogenerate dependency files, and then tweak them a bit using sed. The relevant portion of the makefile: $(OBJ_DIR)/%.d: $(SRC_DIR)/%.cpp $(CPPC) -MM -MD $< -o $@ sed -i 's|\(.*\)\.o:|$(OBJ_DIR)/\1.o $(OBJ_DIR)/\1.d $(TEST_OBJ_DIR)/\1_utest.o:|' $@ While this runs with no trouble under GNU/Linux, I get errors like the following when attempting to build on OSX: sed: 1: "test/obj/equipmentConta ...": undefined label 'est/obj

shell script replace variables in file - error with Sed's -i option for in-place updating

你。 提交于 2019-11-26 17:20:30
问题 Here is my test.env RABBITMQ_HOST=127.0.0.1 RABBITMQ_PASS=1234 And I want to use test.sh to replace the value in test.env to : RABBITMQ_HOST=rabbitmq1 RABBITMQ_PASS=12345 here is my test.sh #!/bin/bash echo "hello world" RABBITMQ_HOST=rabbitmq1 RABBITMQ_PASS=12345 Deploy_path="./config/test.env" sed -i 's/RABBITMQ_HOST=.*/RABBITMQ_HOST='$RABBITMQ_HOST'/' $Deploy_path sed -i 's/RABBITMQ_PASS=.*/RABBITMQ_PASS='$RABBITMQ_HOST'/' $Deploy_path But I have error sed: 1: "./config/test.env": invalid