Using the Windows port of SED?

Microsoft Windows
Post Reply
Posts: 4
Joined: 2021-Aug-15, 11:29 pm

Using the Windows port of SED?

Post by Rekrul »

This page;

Includes Windows ports of Linux utilities. I downloaded the Windows port of SED 4.2.1, however I literally can't get it to do anything. I have copied numerous examples off the net and even off the SED documentation page, but no matter what I try, all I get is;

sed: -e expression #1, char 1: unknown command: `''

To test it, I created a one-line text file with the line "This is a test", then I issued the command;

Code: Select all

sed 's/test/text/' test.txt
Which the documentation says will do a search and replace on the given file. Nope. I just get that stupid error.

I have tried other examples as well and none of them work. I thought maybe it might be a problem with SED expecting a newer version of Windows than I have (I have an old system), so I found an older version, 3.02 and that does the same exact thing!

I'm at a loss here. Does the Windows port of SED just not work? Is there some other parameter I need to include that isn't mentioned anywhere on the net?
User avatar
Simon Sheppard
Posts: 62
Joined: 2021-Jul-10, 7:46 pm

Re: Using the Windows port of SED?

Post by Simon Sheppard »

The GnuWin32 version of sed only supports double quotes, because thats all the CMD shell understands.

Code: Select all

sed "s/test/text/" test.txt
An alternative would be to run Cygwin, which is more like a Unix shell so I think it gives you more quoting options.
Post Reply