Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Get-Content test.txt | ForEach-Object { $_ -replace "foo", "bar" } | Set-Content test2.txt
- fart.exe -p -r -c -- C:toolsperl-5.8.9* @@APP_DIR@@ C:tools
- sed -c s/FOO/BAR/g filename
- set str=teh cat in teh hat
- echo.%str%
- set str=%str:teh=the%
- echo.%str%
- teh cat in teh hat
- the cat in the hat
- set value=new_value
- :: Setup initial configuration
- :: I use && as the delimiter in the file because it should not exist, thereby giving me the whole line
- ::
- echo --> Setting configuration and properties.
- for /f "tokens=* delims=&&" %%a in (configconfig.txt) do (
- call replace.bat "%%a" _KEY_ %value% configtemp.txt
- )
- del configconfig.txt
- rename configtemp.txt config.txt
- @echo off
- :: This ensures the parameters are resolved prior to the internal variable
- ::
- SetLocal EnableDelayedExpansion
- :: Replaces Key Variables
- ::
- :: Parameters:
- :: %1 = Line to search for replacement
- :: %2 = Key to replace
- :: %3 = Value to replace key with
- :: %4 = File in which to write the replacement
- ::
- :: Read in line without the surrounding double quotes (use ~)
- ::
- set line=%~1
- :: Write line to specified file, replacing key (%2) with value (%3)
- ::
- echo !line:%2=%3! >> %4
- :: Restore delayed expansion
- ::
- EndLocal
- Const ForReading = 1
- Const ForWriting = 2
- strFileName = Wscript.Arguments(0)
- strOldText = Wscript.Arguments(1)
- strNewText = Wscript.Arguments(2)
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objFile = objFSO.OpenTextFile(strFileName, ForReading)
- strText = objFile.ReadAll
- objFile.Close
- strNewText = Replace(strText, strOldText, strNewText)
- Set objFile = objFSO.OpenTextFile(strFileName, ForWriting)
- objFile.WriteLine strNewText
- objFile.Close
- perl -pi.orig -e "s/<textToReplace>/<textToReplaceWith>/g;" <fileName>
- for %x in (<filePattern>) do perl -pi.orig -e "s/<textToReplace>/<textToReplaceWith>/g;" %x
Add Comment
Please, Sign In to add comment