AnswerBun.com

Sed for windows

Super User Asked by TheSavo on December 17, 2020

I am attempting to use SED for the first time. To complicate matters, I am using it in Windows. I downloaded from this source. Since I don’t have installation privileges on my work machine, I created a folder in my profile for executables and added it to my PATH.

I am having issues trying to use SED for the first time. It keeps failing with the error:

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

I have tried a few different samples from this how to, but I just can’t get it. I found noone else is having this problem. What should I try? I have tried encapsulating it in quotes, double quotes, and back-quotes. Nothing seems to help.

2 Answers

C:>sed sdf
sed: -e expression #1, char 3: Unterminated `s' command

C:>echo aaa > f
C:>sed -e "s/a/x/" < f
xaa

This is using sed from unxutils

Correct answer by RedGrittyBrick on December 17, 2020

Unlike the Unixes, the Windows command-line shell does not perform any word-splitting and does not strip away the quotes; the program just receives a single string containing the entire command line. This means that not all programs can follow the same quoting rules.

In this case, the GnuWin32 version of sed only supports one quoting style – " double quotes ". For example, in my tests the following works fine:

sed "s/foo/bar/"

You can also get sed from Cygwin, along with a more-complete Unix-like system: shells, editors, other tools. It will be easier if you use a Unix shell for learning, to avoid such syntax issues in the future.

Answered by user1686 on December 17, 2020

Add your own answers!

Related Questions

Dreamweaver hangs when opening or viewing a file

2  Asked on December 11, 2020 by kallum-tanton

       

Import passwords from Firefox to LastPass

2  Asked on December 10, 2020 by noamtm

     

UPS vs PSU wattage during normal operation?

0  Asked on December 9, 2020 by mike-lasch

     

USB MIDI keyboard losing events on Windows 10

0  Asked on December 9, 2020 by mikhail-ramendik

     

Preparing a ZFS based setup for a potential future upgrade

0  Asked on December 9, 2020 by trinity-1686a

   

Add a new disk as mirroring (raid 1) to existing disk

1  Asked on December 9, 2020 by user13727833

       

ClamAV exclude on some signature does not work

0  Asked on December 9, 2020 by kalib-zen

 

Windows 10 keeps opening apps on its own

0  Asked on December 9, 2020 by karlabos

     

Can I know how vice uses .vkm files

0  Asked on December 8, 2020 by cody-ferguson

 

Disable internal speaker only on Windows 10 Dell

2  Asked on December 8, 2020 by fire-lancer

     

Why my CPU never work on the maximum multiplier

1  Asked on December 8, 2020 by notrust

 

Selective counting up in Excel

1  Asked on December 8, 2020 by nm82

 

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP