1.

Solve : Changing a character in text?

Answer»

need help to Changing a character in text


[AR]
a=Setup.exe
b=Setup.exe


change to....


[AR]
echo Setup.exe
echo Setup.exe


a= and b= change to echo


how to write in batch? please help meWhat OS are you using?i'm using windows sp2

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.The following is not batch, but an example in powershell and windows services for unix. both can be downloaded from M$.
Powershell eg
type this code and save as change.ps1
Code: [Select]$pattern1="^a="
$pattern2="^b="
$REPLACEMENT="echo"
FOREACH($text in (get-content yourfile.txt)) {
if ($text -match $pattern1) {
$text = $text -replace $pattern1, $replacement
echo $text
}
elseif ( $text -match $pattern2) {
$text = $text -replace $pattern2, $replacement
echo $text
}
else { echo $text}
}
then on cmd , type
Code: [Select]C:\temp>powershell -nologo -noninteractive -command "& c:\TEST\change.ps1" > new

using Windows for Unix services :
Code: [Select]/dev/fs/C/SFU/bin/awk -F"=" '/^a=/ || /^b=/{$1="echo";}
{print} ' yourfile.txt
save as change.sh, then on cmd:
Code: [Select]C:\test> ksh test.sh
Not your NORMAL batch, but something else to add to your the toolbox.Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\asda>C:\temp>powershell -nologo -noninteractive -comma
nd "& c:\test\change.ps1" > new
'C:\temp' is not recognized as an internal or external command,
operable program or batch file.


wat is windows for unix services?

Quote from: insertusername on May 26, 2007, 02:58:14 AM

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\asda>C:\temp>powershell -nologo -noninteractive -comma
nd "& c:\test\change.ps1" > new
'C:\temp' is not recognized as an internal or external command,
operable program or batch file.


wat is windows for unix services?


c:\temp is just my directory where i did my tests scripts...dude you don't even know your command prompt.
Actually its services for windows. Its Unix in windows , that means you can do unix stuff in windows...SEE here


Discussion

No Comment Found