0

I have a text file that has a number in every new line and all are in ascending order.

Contents are like :

1 13 25 37 49 97 109 121 

I want to extract only those numbers who have difference greater than 12, with the previous number. I wish to use batch program for this....

How can I do that ?

1
  • 1
    This strongly looks like a homework assignment - not good... Commented Dec 26, 2012 at 18:42

1 Answer 1

2

I would have liked to see you make an attempt but anyway I had a go and this is the closest I could get

c:\temp>type test.txt 1 line 1 10 line 1a 13 line 2 25 line 3 22 line 3a 37 line 4 49 line 5 97 line 6 109 line 7 121 line 8 c:\temp>test.bat 25 line 3 37 line 4 49 line 5 97 line 6 109 line 7 121 line 8 c:\temp> 

using this code in test.bat:

@echo off SETLOCAL ENABLEDELAYEDEXPANSION set /a cur="0" for /f "tokens=1,* delims= " %%a in ('type test.txt') do ( set line=%%a %%b set /a num="%%a" set /a dif="!num!-!cur!" if !dif! geq 12 @echo !line! set /a cur="%%a" ) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.