Home > Software design >  Add four spaces before each line of code in terminal [Windows]
Add four spaces before each line of code in terminal [Windows]

Time:02-16

Is there any faster way to add fours spaces to each line except by manually adding it? How could it be done from a terminal in Windows?

sed 's/^/    /' file

This would work on unix/linux. How could this command be written in Windows?

  • I get this error:

    'sed' is not recognized as an internal or external command, operable program or batch file.

CodePudding user response:

As sed is not recognised, you won't be able to use it, so you need to install it first, as already mentioned by Wiktor.

In order to do this, there are two typical ways:

  • Install Cygwin, this contains a list of UNIX/Linux-like programs which you can use as commandline programs.

  • Install a Windows subsystem for Linux. Once you have that, you can run every UNIX/Linux-like program, using wsl <command>, as you can see in this example:

    Windows command prompt>wsl sed
    Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...
    
  • Related