You are not logged in.
Hi Gurus,
I am totally new to DOS. Infact I am a Java guy. I need to do some string search operations but unfortunately string search & file search operation in java is considerably slow. And its very fast in OS.
So here is my problem. I need to find some files with fixed extension (.sp) for strings (lines) between 2 fixed characters. They are ';' & ';'
Here is the content of one of .sp file.
File:- Tons.sp
line 1: Skipcheck;
line 2: [Scenario:'Actual']=STET;
line 3: ['WFS':'Actual','Scenario':'Actual','Measure':'Units']=N:
line 4: IF( SUBST( !Measure, 1, 1) @= '8'
line 5: ,
line 6: ['Amount']
line 7: ,
line 8: STET
line 9: );
line10:
line11: ['Tons'] = N:
line12: DB('Volume Master',!Version,!Year,!Plant,'GL_CODE_0004',!Period,!Measure) ;
line13:
line14: ['Group1_Volume'] = N:
line15: IF ( ELISANC( 'Plant', 'Group1' , !Plant )=1
line16: , ['Take_This']
line17: , CONTINUE
line18: );
line19:
line20: ['Tons Trend']=N:
line21: IF( DB('Monthly_Trend', !Period, 'Tons_Trend_Factor') > 0
line22: , 'Current_Tons' * DB('Volume Master',!Version,!Year,!Plant,'GL_CODE_TonsProduced',!Period,!Measure)
line23: , CONTINUE
line24: );
Please Note: line numbers are just for indication.
Problem 1: Now I need to find the string (all lines) that lie between ';' & ';' that contains string "DB('Volume Master'"
ie.: The findstring will be something like this:-
FINDSTR /n "=*DB('Volume Master'*;" *.sp
The result of above command should be line 11 to 12 & line 20 to 24
line11: ['Tons'] = N:
line12: DB('Volume Master',!Version,!Year,!Plant,'GL_CODE_0004',!Period,!Measure) ;
&
line20: ['Tons Trend']=N:
line21: IF( DB('Monthly_Trend', !Period, 'Tons_Trend_Factor') > 0
line22: , 'Current_Tons' * DB('Volume Master',!Version,!Year,!Plant,'GL_CODE_TonsProduced',!Period,!Measure)
line23: , CONTINUE
line24: );
Problem 2: The output of this:-
FINDSTR /n "=*DB('Volume Master'*'GL_CODE_TonsProduced'*;" *.sp
would be:-
line20: ['Tons Trend']=N:
line21: IF( DB('Monthly_Trend', !Period, 'Tons_Trend_Factor') > 0
line22: , 'Current_Tons' * DB('Volume Master',!Version,!Year,!Plant,'GL_CODE_TonsProduced',!Period,!Measure)
line23: , CONTINUE
line24: );
Please help. Thanks
Krishna
Offline
So here is my problem. I need to find some files with fixed extension (.sp) for strings (lines) between 2 fixed characters. They are ';' & ';'
Problem 1: Now I need to find the string (all lines) that lie between ';' & ';' that contains string "DB('Volume Master'"
ie.: The findstring will be something like this:-
FINDSTR /n "=*DB('Volume Master'*;" *.spThe result of above command should be line 11 to 12 & line 20 to 24
line11: ['Tons'] = N: line12: DB('Volume Master',!Version,!Year,!Plant,'GL_CODE_0004',!Period,!Measure) ;
You have written between two semicolons ; but the line you have shown doesn't have a semicolon anywhere except at the end.
Explain how your line11 and line12 appears when you are matching text between two semicolons
It seems that you are trying to perform multi-line compares, but in that case line10 should appear as well, and line 12 should not have the semicolon at the end.
Last edited by foxidrive (15 Jun 2014 09:52)
Offline
Hi foxidrive,
you are right line 10, should also appear. Sorry, my bad. And for 2nd string match pattern line 19 to 24 should appear. I have done it in java but its slow. I need to search about 300 files of 1 mb each which is heavy for java. And I am sure findstr will do it considerable faster.
Can you please help.
Thanx!
Offline
It would be useful to know the kind of variation there can be in the text in the files, and how many occurrences of the string there can be per file.
Plain batch relies heavily on the format of the files - and findstr is not designed to to multi-line compares, though it can be forced to do so if the makeup of the files is clearly defined.
Offline