I have variable
test="PlayLists: 00001.mpls 01:32:39 [12 chapters] 00005.mpls 00:19:37 [4 chapters] 00003.mpls 00:08:56 [1 chapters] 00004.mpls 00:00:39 [1 chapters] 00006.mpls 00:00:29 [2 chapters] 00007.mpls 00:00:25 [2 chapters] 00000.mpls 00:00:23 [1 chapters]"
I tried with:
chapters=$([[ $test =~ ((([0-9]+) chapters)+) ]] && echo "${BASH_REMATCH[1]}")
echo $chapters
But it returns only 12 chatpters
, I want to get
12 chapters
4 chapters
1 chapters
...