I have a file with a name file.txtthat contains absolute paths. It looks like this:
J:/Folder/inner
J:/Folder/inner2
At first I wanted to write a bash script that replaces J:/with /cygdrive/j/. So I did it like this:
sed -i 's/J:\//\/cygdrive\/j\//g' file.txt
and works as expected.
But now I need something more sophisticated: the absolute paths do not need to begin with J- they can start with a C, D, E...
I want to do the same as above, only because I do not know what will be the first letter. For example: it C:/Folder/innerwill become /cygdrive/c/Folder/inner, but it D:/Folder/innerwill become /cygdrive/d/Folder/inner.
I understand that I need to use regex to achieve this, but I have not found a way to do this. Do you know how I can get what I want?
source
share