Computer Hope

Microsoft => Microsoft DOS => Topic started by: davidmcm on December 30, 2021, 03:33:31 PM

Title: How to run sed.exe in Windows10
Post by: davidmcm on December 30, 2021, 03:33:31 PM
On BSD, I've been running runsed with sedscr for many years.

The sedscr would have a line like s/abc/ABC/
The runsed script I'll paste below. The command would be runsed filename

I just don't know how to get sed.exe to work. The main problem is setting the permissions in Window10. I try right-clicking the sed icon on my desktop and clicking Run as administrator but still does not work.

And I am hoping once that is cleared up, a command like this will work at DOS command line: sed s/abc/ABC/ filename
And beyond that: sed s/abc/ABC/ *.html

Is there hope?

for x
do
echo "editing $x: \c"
if test "$x" = sedscr; then
        echo "Not editing sedscript!"
elif test -s $x; then
        sed -f sedscr $x > /tmp/$x
        if test -s /tmp/$x
        then
        cmp -s $x /tmp/$x && echo "File not changed: \c"; cp /tmp/$x $x;echo "Done."
        else
        echo "Sed produced an empty file -- check sedqscript"
        fi
else
        echo "original file in empty"
fi
done
echo "all done."


Title: Re: How to run sed.exe in Windows10
Post by: nil on December 30, 2021, 07:04:43 PM
On Windows 10 Your best bet is to run WSL which will provide access to bash and GNU sed on your Windows file system

https://docs.microsoft.com/en-us/windows/wsl/install