Answer the question
In order to leave comments, you need to log in
Double quotes in sed regular expressions in a DOS environment
Hello dear!
Started learning the Win32 port of sed for a few trivial tasks. And almost immediately I ran into a problem (which, I think, is not surprising). Reading various resources and doing all kinds of searching does not help, and there is no time for deep study of regular expressions (where there is probably an answer). Please help!
Problem
There is a file containing the following line:
if file_getprop("/system/build.prop","ro.build.display.id")!="ROM v.6.0 beta" then
6.0 beta
with the value of the variable set when starting the batch file, while the specified part can be of any length, for example, 6.0 alpha
and may not contain alphabetic characters, for example, 6.0
. To solve the problem in a single-line script, I wanted to use the symbol " (double quotes), however, in this case, the utility does not work correctly. @echo off
set MOD=d:\ROM\KITCHEN\MOD
set UnxUtils=d:\ROM\KITCHEN\TOOLS\UnxUtils\usr\local\wbin
set TEMP=d:\ROM\KITCHEN\TEMP
set /p ROMVER=Введите версию прошивки:
%UnxUtils%\sed.exe -e "/ROM/s/v\..*"/v.%ROMVER%"/g" %MOD%\META-INF\com\google\android\aroma-config > %TEMP%\aroma-config
move /y %TEMP%\aroma-config %MOD%\META-INF\com\google\android\aroma-config
pause
if file_getprop("/system/build.prop","ro.build.display.id")!="ROM v.6.0 beta" then
1.0
, then the output is the following:if file_getprop("/system/build.prop","ro.build.display.id")!="ROM v.1.0
Answer the question
In order to leave comments, you need to log in
Answered on another resource, two things had to be done:
1. Use a newer version of the sed utility.
2. Replace the quotes in the body of the script with \x22
.
The final code should look like this:
@echo off
set MOD=d:\ROM\KITCHEN\MOD
set UnxUtils=d:\ROM\KITCHEN\TOOLS\UnxUtils\usr\local\wbin
set TEMP=d:\ROM\KITCHEN\TEMP
set /p ROMVER=Введите версию прошивки:
%UnxUtils%\sed.exe -e "/ROM/s/v\..*\x22/v.%ROMVER%\x22/g" %MOD%\META-INF\com\google\android\aroma-config > %TEMP%\aroma-config
move /y %TEMP%\aroma-config %MOD%\META-INF\com\google\android\aroma-config
pause
@echo off
set MOD=d:\ROM\KITCHEN\MOD
set UnxUtils=d:\ROM\KITCHEN\TOOLS\UnxUtils\usr\local\wbin
set TEMP=d:\ROM\KITCHEN\TEMP
set /p ROMVER=Введите версию прошивки:
%UnxUtils%\sed.exe -e "/ROM v/s/\(ROM v\.\)[^\x22]*\x22/\1%ROMVER%\x22/g" %MOD%\META-INF\com\google\android\aroma-config > %TEMP%\aroma-config
move /y %TEMP%\aroma-config %MOD%\META-INF\com\google\android\aroma-config
pause
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question