RE: [BATCH WORLD] Re: SED Question
- Thanks Garry, I'll test and add to my scripts folder.
From: email@example.com [mailto:firstname.lastname@example.org] On
Behalf Of Garry Deane
Sent: Friday, July 27, 2007 3:50 AM
Subject: [BATCH WORLD] Re: SED Question
--- In email@example.com <mailto:batchworld%40yahoogroups.com>
, foxidrive <foxidrive@...> wrote:
>a\wyse\wnos\wnos.ini^|find /n /v ""^|find ""'
> Another day, another batch file. ;-)
> This has been tested (my apologies for omitting that info to
> begin with in this thread) but has had the specific paths added
> and variable changed to %%a, which have not been tested.
> @echo off
> FOR /F "TOKENS=1" %%a IN (name.txt) DO (
> for /f "tokens=2 delims=" %%b in (
> 'find /n "Reconnect="^<%%
> ) do (a\wyse\wnos\wnos.ini>c:\a.txt
> sed "%%b s/Reconnect.../Reconnect=90/" %%
> move c:\a.txt %%a\wyse\wnos\wnos.iniMaybe I'm missing something here but this seems overly complex.
> It is 10 lines in total and should change only the first
> occurance of "Reconnect=" in the ini file.
> The triplet of find commands detect firstly all the "Reconnect="
> lines, and provides the line numbers using /n, then takes the
> first of those (by renumbering those lines again) and uses the
> first line number in the sed command to change only that line.
You can use the line range syntax in sed to only search and
replace up to the first occurrence of "Reconnect=" e.g.
sed "1,/Reconnect=/s/Reconnect=../Reconnect=90/" < in.txt > out.txt
[Non-text portions of this message have been removed]
- I have the following question about sed and methacaracters:
In the eg number 1, I escaped the +, to get any matches with 1 plus (1 or
In the eg number 2, I escaped the *, to get any matches with 0 or more
characters, but it scape the * and takes it at literal.
Why it doesn't take + literal as well?
How does it really works?
1.) sed -ne '/t\+/Ip'
tango > repeated
balada > non repeated
2.) sed -ne '/t\*/Ip'
View this message in context: http://www.nabble.com/SED-Question-tp25892283p25892283.html
Sent from the Batch World mailing list archive at Nabble.com.