This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Saving Lines between "start"s and "end"s as different arrays in bash script

Hello everyone,

I have a file that consists of a bunch of things but what I need are numbers between start and end strings: For example :

ghghgh
start
23
34
22
12
end
ghbd
wodkkh
234
start
14
56
74
end

So, I need two arrays here one containing 23,34,22,12 and one containing 14,56,74. What's the best command to use?

If I only had one start and one end I would be able to use mapfile and awk to obtain that array, but there's many start and ends in the file and I need to save all the arrays.

bash

You should search for answers to questions like this on stackoverflow. This post will likely be closed.

0 answers

No answers yet.

Log in to answer this question.