Search code examples
replacemakefilepath-separator

Simple way of converting slashes in a 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.


Solution

  • 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.