Tool to change \ to /

May 29, 2018 at 8:39pm
Hi
I wasn't sure whether to post this here or under linux programming
but since it doesn't really have anything to do with c++ i just posted it here. sorry if its wrong.

basically: i have this codebase where i used "\" in all my include paths and now i need to build it on linux...which is a problem because apparently on linux you use / for filepaths

so i was just wondering: does anyone know of a tool that can autoamtically go through all my sourcefiles and change the the backslashes to forwardslashes?

thanks :)
Last edited on May 29, 2018 at 8:42pm
May 30, 2018 at 3:02am
Untested, but in bash, something like this?
find . \( -name '*.cpp' -o -name '*.h' \) -exec sed -i '/^#include/ s/\\/\//g' {} \;
Last edited on May 30, 2018 at 3:24am
May 30, 2018 at 4:50am
This issue is a good reason to always use the forward solidus ( / ) as a path separator, even on Windows.
It's also illustrative of a good reason to learn the command line.
May 30, 2018 at 9:21am
Why don't you write a little tool yourself ?
Should be simple and straightforward.
Topic archived. No new replies allowed.