makefile中sed命令的字符串参数怎么分行写

jackchzj 2014-09-13 06:32:17
例如

makefile
all:
sed \
's/111/222/g; \
s/333/444/g;' \
file_001 > file_002

$make
makefile:2: target 'all' does not exist
sed \
's/111/222/g; \
s/333/444/g;' \
file_001 > file_002
sed: -e expression #1, char 27: unterminated address regex
makefile:2: recipe for target 'all' failed
make: *** [all] Error 1
...全文
290 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackchzj 2014-09-15
  • 打赏
  • 举报
回复
引用 5 楼 zhao4zhong1 的回复:
搜“makefile 续行符”?
我的例子里不是用了续行符吗?难道还有别的用法?阁下要是知道的话请直接告诉我。
赵4老师 2014-09-15
  • 打赏
  • 举报
回复
搜“makefile 续行符”?
jackchzj 2014-09-15
  • 打赏
  • 举报
回复
引用 3 楼 zhao4zhong1 的回复:
搜“跟我一起写makefile”?
能告诉我第几章第几节吗?
赵4老师 2014-09-15
  • 打赏
  • 举报
回复
搜“跟我一起写makefile”?
jackchzj 2014-09-15
  • 打赏
  • 举报
回复
[quote=引用 10 楼 mujiok2003 的回复:] 使用-e 选项, 注意2,-4行头的空格
引用
1 sed \ 2 -e 's/xxxx/yyyy/g'\ 3 -e 's/yyyy/xxxx/g'\ 4 demo.c [/quote】
这个对了,谢谢
mujiok2003 2014-09-15
  • 打赏
  • 举报
回复
使用-e 选项, 注意2,-4行头的空格[quote] 1 sed \ 2 -e 's/xxxx/yyyy/g'\ 3 -e 's/yyyy/xxxx/g'\ 4 demo.c [/quote】
jackchzj 2014-09-15
  • 打赏
  • 举报
回复
引用 7 楼 zhao4zhong1 的回复:
all: sed \ 's/111/222/g; \ s/333/444/g;' \ file_001 > file_002
这跟我一楼举的反例不是一样吗?
赵4老师 2014-09-15
  • 打赏
  • 举报
回复
Commands in a Makefile Home Page (Projects) | Overview (NMAKE Reference) | How Do I... Topics (Projects) A description block or inference rule specifies a block of commands to run if the dependency is out-of-date. NMAKE displays each command before running it, unless /S, .SILENT, !CMDSWITCHES, or @ is used. NMAKE looks for a matching inference rule if a description block is not followed by a commands block. A commands block contains one or more commands, each on its own line. No blank line can appear between the dependency or rule and the commands block. However, a line containing only spaces or tabs can appear; this line is interpreted as a null command, and no error occurs. Blank lines are permitted between command lines. A command line begins with one or more spaces or tabs. A backslash ( \ ) followed by a newline character is interpreted as a space in the command; use a backslash at the end of a line to continue a command onto the next line. NMAKE interprets the backslash literally if any other character, including a space or tab, follows the backslash. A command preceded by a semicolon (;) can appear on a dependency line or inference rule, whether or not a commands block follows: project.obj : project.c project.h ; cl /c project.c What do you want to know more about? Command modifiers Filename-parts syntax Inline files in a makefile
赵4老师 2014-09-15
  • 打赏
  • 举报
回复
all: sed \ 's/111/222/g; \ s/333/444/g;' \ file_001 > file_002
勤奋的小游侠 2014-09-14
  • 打赏
  • 举报
回复
后面的几行不要用tab。
jackchzj 2014-09-14
  • 打赏
  • 举报
回复
引用 1 楼 lovesmiles 的回复:
后面的几行不要用tab。
不行啊,一样

64,282

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧