This is an alternate way to approach it. You may like it for its simplicity. This script takes 3 arguments.
m - starting line number
n - ending line number
file - path to the input text file
Code:
# Script m2n.txt
var str file, m, n, content
cat $file > $content
#Remove everything after line number $n
lex ($n+"[") $content > null
#Remove everything upto line number $m
lex ("]"+$m) $content > null
echo $content
Note that you have to remove lines after $n first, then remove lines upto $m. If you remove the beginning lines first, the line numbers will shift.
Script is in biterscripting. Save it in file C:/Scripts/m2n.txt, run it as
script "C:/Scripts/m2n.txt" file("/path/to/file.txt") m("2") n("5")
Will extract lines 2 thru 5.
Bookmarks