working with Findstr

Microsoft Windows vista home premium w/s...
February 9, 2010 at 15:52:19
Specs: Windows Vista
How to find the following using findstr please help..

File:

config t
zoneset name Prod_01 vsan 105
zone name DMX3904_07cb_CSCDWSCS01
member fcalias DMX3904_07cb_8c52a89826
member fcalias CSCDWSCS01_ab2e
exit
zone name DMX3904_07cb_CSDATG07
member fcalias DMX3904_07cb_8c52a89826
member fcalias CSDATG07_0c79
exit
exit
exit
exit

OUTPUT File:

zone name DMX3904_07cb_CSDATG07
member fcalias DMX3904_07cb_8c52a89826
member fcalias CSDATG07_0c79


See More: working with Findstr

Report •


#1
February 9, 2010 at 20:11:13
You need to define the criteria.


=====================================
Helping others achieve escape felicity

M2


Report •

#2
February 10, 2010 at 05:33:45
I am new to cmd scripting... Sorry for that..

The criteria is , I want to search the line with CSDATG07 and copy that line along with two consecutive lines in a new file..

Please help!

Regards,
Ash


Report •

#3
February 10, 2010 at 07:09:14
That string is in at least 2 lines.

As ever, a solution starts with a clear problem statement.


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
February 10, 2010 at 07:57:11
Ok.. consider the following example...

config t
zoneset name Prod_01 vsan 105
zone name DMX3904_07cb_CSCDWSCS01
fc_23409128328c52a89826
093287437824938747_ab
exit
zone name DMX3904_07cb_CSDATG07
97249057294375_kjdsf
09845u8gkl098w09803
exit
exit
exit
exit

what should be the program to search for string CSDATG07 and copy the next two lines along with the searched line to a new file...

Please help.. I urgently need it!

Regards,
Ash


Report •

#5
February 10, 2010 at 08:30:19
@echo off > newfile & setLocal enableDELAYedeXpansion

for /f "tokens=1 delims=[]" %%a in ('find /n "CSDATG07" ^< myfile') do (
set F=%%a
)

set /a G = F + 2
set /a N=0

for /f "tokens=* delims= " %%a in (myfile) do (
set /a N+=1
if !N! geq !F! if !N! leq !G! (
>> newfile echo %%a
)
)


=====================================
Helping others achieve escape felicity

M2


Report •

#6
February 10, 2010 at 09:13:41
Thanks Alot !!! Appreciate it very much!

Report •


Ask Question