Discussion:
Sed --in-place creates new file
(too old to reply)
Jérémy Amiot
2020-04-05 09:57:20 UTC
Permalink
Hi,

Using sed for windows version 4..2.1 (url :
http://gnuwin32.sourceforge.net/packages/sed.htm)

sed -i "s/to/ti/" test.txt will modify test.txt (ok) but will create a
new file "sedGnChQb"
sed -i"" "s/to/ti/" test.txt does the same new file

How to avoid sed to create a new file ?

Thanks a lot.
Bob Proulx
2020-04-07 00:31:02 UTC
Permalink
Post by Jérémy Amiot
http://gnuwin32.sourceforge.net/packages/sed.htm)
Very often bugs in Windows versions of tools are due to the port to
Windows being the root cause. Looking at that page it looks like the
last time the Windows port has been touched was 2010 which with it
being 2020 now seems like that project may have been abandoned.

You might try a different port to windows. Either Cygwin or Mingw or
UnxUtils or MSYS or something.
Post by Jérémy Amiot
sed -i "s/to/ti/" test.txt will modify test.txt (ok) but will create a
new file "sedGnChQb"
sed -i"" "s/to/ti/" test.txt does the same new file
How to avoid sed to create a new file ?
You have reached bug-gnu-utils which is a catch-all list for random
utilities. But sed has it's own mailing list at bug-sed AT gnu.org.
If you want to reach the sed mailing list then that is the place.

I am not running Microsoft so can't test or try but this is not normal
behavior elsewhere. I suspect without being able to check that it is
a problem with the port and does not exist in the upstream sed code.
I strongly suggest looking at one of the ports that has a version
better matched to your current system. Because no current Windows
system today existed ten years ago when your current port was made.
Looking at the system requirements on the page you listed it looks
like all of those systems are now out of support.

Looking at your listed URL I see a reference to this to post bugs.

http://gnuwin32.sourceforge.net/packages/sed.htm

That looks problematic because the archives links are no longer
available. But the GnuWin bug reporting pages look to be current and
active.

https://sourceforge.net/p/gnuwin32/bugs/

Good luck!
Bob
Jérémy Amiot
2020-04-07 09:20:56 UTC
Permalink
Hi Bob,
Thanks! Indeed, this bug "#534 Temporary files are not deleted with
inplace parameter"
have been created on 2011-02-03 (https://sourceforge.net/p/gnuwin32/bugs/534/)
and no solution/update have been found so far.
I've checked UnxUtils as well, it's worse (back to 2004 with sed version 3.x).
Nevermind I'll use other tools (WSL on Windows seems to be the better bet).
Have a great day and take care.
Post by Bob Proulx
Post by Jérémy Amiot
http://gnuwin32.sourceforge.net/packages/sed.htm)
Very often bugs in Windows versions of tools are due to the port to
Windows being the root cause. Looking at that page it looks like the
last time the Windows port has been touched was 2010 which with it
being 2020 now seems like that project may have been abandoned.
You might try a different port to windows. Either Cygwin or Mingw or
UnxUtils or MSYS or something.
Post by Jérémy Amiot
sed -i "s/to/ti/" test.txt will modify test.txt (ok) but will create a
new file "sedGnChQb"
sed -i"" "s/to/ti/" test.txt does the same new file
How to avoid sed to create a new file ?
You have reached bug-gnu-utils which is a catch-all list for random
utilities. But sed has it's own mailing list at bug-sed AT gnu.org.
If you want to reach the sed mailing list then that is the place.
I am not running Microsoft so can't test or try but this is not normal
behavior elsewhere. I suspect without being able to check that it is
a problem with the port and does not exist in the upstream sed code.
I strongly suggest looking at one of the ports that has a version
better matched to your current system. Because no current Windows
system today existed ten years ago when your current port was made.
Looking at the system requirements on the page you listed it looks
like all of those systems are now out of support.
Looking at your listed URL I see a reference to this to post bugs.
http://gnuwin32.sourceforge.net/packages/sed.htm
That looks problematic because the archives links are no longer
available. But the GnuWin bug reporting pages look to be current and
active.
https://sourceforge.net/p/gnuwin32/bugs/
Good luck!
Bob
Continue reading on narkive:
Loading...