Simple way of converting slashes in a Makefile?

送分小仙女□ 提交于 2019-12-24 07:06:24

问题


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.


回答1:


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.




回答2:


I think that Gregs solution was nearly correct, but I would do

sed -e 's/\\\(.\)/\/\1/g'

to make sure that not only the first slash gets replaced. Sorry for not doing this as a comment, but I don't have the privilege yet.



来源:https://stackoverflow.com/questions/4060744/simple-way-of-converting-slashes-in-a-makefile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!