Replace double quotes with space using sed or tr command in windows batch file Replace double quotes with space using sed or tr command in windows batch file unix unix

Replace double quotes with space using sed or tr command in windows batch file


sed "s/\x22/ /g" "input.txt" tr "\""" " "   < "input.txt"tr """" " "    < "input.txt"tr \""  " "    < "input.txt"


Why using Unix tools and not native Windows commands for this simple task?

@echo offif not exist "File1.txt" goto :EOFsetlocal EnableDelayedExpansiondel "File2.txt" 2>nulfor /F "usebackq delims=" %%I in ("File1.txt") do (    set "Line=%%I"    set "Line=!Line:"= !"    echo !Line!>>"File2.txt")endlocal

Note: The command FOR as used here skips empty lines and lines starting with a semicolon.

I would replace the double quotes by nothing which means deleting the space character after equal sign.

For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.

  • del /?
  • echo /?
  • endlocal /?
  • for /?
  • goto /?
  • if /?
  • set /?
  • setlocal /?

Read also the Microsoft article about Using Command Redirection Operators.