在Makefile中转换斜杠的简单方法? [英] Simple way of converting slashes in a Makefile?
问题描述
我需要将所有带有'\'的路径转换为'/'. makefile很长,因此无法手动执行.
I need to convert all paths with '\' in them to '/'. The makefile is quite long and doing this manually is impossible.
有什么方法可以快速转换它们?请记住,不可能进行全局替换,因为'\'也用于表示命令在下一行继续.
Is there some way to quickly convert them? Keep in mind that a global replace is not possible because '\' is also used to denote that a command is continued on the following line.
推荐答案
您似乎可以使用sed
命令来做到这一点:
It looks like you could do this with a sed
command:
sed -e 's/\\\(.\)/\/\1/g'
这会将任何反斜杠后跟其他字符(不包括换行符)转换为正斜杠再跟同一个字符.
This converts any backslash followed by some other character (which doesn't include newline) into a forward slash followed by that same character.
此命令行有点倾斜牙签"问题,对此感到抱歉.
This command line has a bit of a "leaning toothpick" problem, sorry about that.
这篇关于在Makefile中转换斜杠的简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!