sed 批量修改Makefile文件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sed 批量修改Makefile文件相关的知识,希望对你有一定的参考价值。
Makefile文件太多
[[email protected] DarwinStreamingSrvr6.0.3-Source]# find -name Makefile.POSIX ./APIModules/QTSSDemoAuthorizationModule.bproj/Makefile.POSIX ./APIModules/QTSSDemoRedirectModule.bproj/Makefile.POSIX ./APIModules/QTSSHomeDirectoryModule/Makefile.POSIX ./APIModules/QTSSRawFileModule.bproj/Makefile.POSIX ./APIModules/QTSSRefMovieModule/Makefile.POSIX ./APIModules/QTSSSpamDefenseModule.bproj/Makefile.POSIX ./CommonUtilitiesLib/Makefile.POSIX ./HTTPUtilitiesLib/Makefile.POSIX ./Makefile.POSIX ./MP3Broadcaster/Makefile.POSIX ./PlaylistBroadcaster.tproj/Makefile.POSIX ./QTFileLib/Makefile.POSIX ./QTFileTools/QTBroadcaster.tproj/Makefile.POSIX ./QTFileTools/QTFileInfo.tproj/Makefile.POSIX ./QTFileTools/QTFileTest.tproj/Makefile.POSIX ./QTFileTools/QTRTPFileTest.tproj/Makefile.POSIX ./QTFileTools/QTRTPGen.tproj/Makefile.POSIX ./QTFileTools/QTSampleLister.tproj/Makefile.POSIX ./QTFileTools/QTSDPGen.tproj/Makefile.POSIX ./QTFileTools/QTTrackInfo.tproj/Makefile.POSIX ./qtpasswd.tproj/Makefile.POSIX ./StreamingLoadTool/Makefile.POSIX ./StreamingProxy.tproj/Makefile.POSIX [[email protected] DarwinStreamingSrvr6.0.3-Source]#
经过查看之后,大多数文件内容格式如下:
.cpp.o: $(C++) -c -o $*.o $(DEFINES) $(C++FLAGS) $*.cpp .c.o: $(CC) -c -o $*.o $(DEFINES) $(CCFLAGS) $*.c
执行批量更换
[[email protected] DarwinStreamingSrvr6.0.3-Source]# find -name Makefile.POSIX | xargs sed -i ‘/.cpp.o/a\\t$(C++) -E -o $*.i $(DEFINES) $(C++FLAGS) $*.cpp‘ [[email protected] DarwinStreamingSrvr6.0.3-Source]# find -name Makefile.POSIX | xargs sed -i ‘/.c.o/a\\t$(CC) -E -o $*.i $(DEFINES) $(CCFLAGS) $*.c‘
批量更换之后:
.cpp.o: $(C++) -E -o $*.i $(DEFINES) $(C++FLAGS) $*.cpp $(C++) -c -o $*.o $(DEFINES) $(C++FLAGS) $*.cpp .c.o: $(CC) -E -o $*.i $(DEFINES) $(CCFLAGS) $*.c $(CC) -c -o $*.o $(DEFINES) $(CCFLAGS) $*.c
本文出自 “李春利” 博客,谢绝转载!
以上是关于sed 批量修改Makefile文件的主要内容,如果未能解决你的问题,请参考以下文章