i have a text file which looks like this:
random useless text
para1
para2
para3
random us
For anything like this, I'd reach for Perl, with its combination of (amongst others) sed
and awk
capabilities. Something like (beware - untested):
my $recording = 0;
my @results = ();
while (<STDIN>) {
chomp;
if (/token 1/) {
$recording = 1;
}
else if (/token 2/) {
$recording = 0;
}
else if ($recording) {
push @results, $_;
}
}