sed: make changes in the same file on Windows

970 views Asked by At

I use sed on Windows (actually under GitBash) and this approach doesn't work.

$ sed -ibak 's/a/b/g' test1
sed: preserving permissions for `./sed004224': Permission denied

Is there any another approach to do this (or maybe fix this)?
(I know about using perl, and we can move a result file to replace source one.)

UPD 1 It works when I run GitBush "as Administrator". Actually logged Windows user is Admin too.

1

There are 1 answers

1
josifoski On

Most probably problem is with permissions of file test1, so solution will be simple to change it to be writable, or excluding -i option and redirecting to new file in writable folder
sed 's/a/b/g' test1 >somepath/newfile