Command line find and replace script

20 Jan 2020

command line

Simple comman line script to replace %LAUNCHER_PATH% with dotnet and %LAUNCHER_ARGS% with .\MySolution.dll inside the default aspnet core 3.1 web.config file

Bash

sed -i 's/%LAUNCHER_PATH%/dotnet/g;s/%LAUNCHER_ARGS%/.\\MySolution.dll/g' web.config

Powershell

(Get-Content .\web.config) -replace '%LAUNCHER_PATH%', 'dotnet' -replace '%LAUNCHER_ARGS%', '.\MySolution.dll' | Set-Content .\web.config

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.