sed -i 's/CFLAGS = -g -O2/& -fPIC/'
原:CFLAGS = -g -O2
修改后:CFLAGS = -g -O2 -fPIC
参考:
linux shell搜索某个字符串,然后在后面加上字符串?字符串后面插入字符串?sed字符串后面插入字符串? - 技术颜良 - 博客园 (cnblogs.com)
ChatGPT
在Makefile中,如果希望在查找到特定字符串之后在其后面添加另一个字符串,可能需要使用某些文本处理工具,如`sed`(Stream Editor)。下面会提供一个基本的示例来说明如何实现这一功能。
假设有一个文本文件`example.txt`,内容如下:
line 1: This is an example
line 2: String not to replace
line 3: Pattern found here
line 4: Another line
line 5: End