sed簡單用法

行前插入:在包含main字符串的行以前插入一行代碼spa

sed -i '/main/i\static void sighandler(int sig_no) {\n    std::cout<<"received signal SIGUSR1"<<std::endl;\n    exit(0);\n}\n' main.cppcode

行後插入:在CFLAGS =下一行插入插入文本CFLAGS += -w -ftest-coverage -fprofile-arcsxml

sed -i '/CFLAGS =/a\CFLAGS += -w -ftest-coverage -fprofile-arcs' ${file}字符串

替換:把PathDecoderD.so替換成PathDecoder.soit

sed -i 's/PathDecoderD\.so/PathDecoder\.so/' config.xml
test

相關文章
相關標籤/搜索