开发者

Simple way of converting slashes in a Makefile?

开发者 https://www.devze.com 2023-01-22 23:28 出处:网络
I need to convert all paths with \'\\\' in them to \'/\'. The makefile is quite long and doing this manually is impossible.

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 g开发者_运维技巧lobal replace is not possible because '\' is also used to denote that a command is continued on the following line.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消