Per me fai prima a farti un parsing a manina.
Giusto per provare, ho buttato giù il seguente scriptino:
- Codice: Seleziona tutto
#!/bin/sh
OWN_START="[OWN]"
OWN_END="[/OWN]"
LISTA_START="[LISTA]"
LISTA_END="[/LISTA]"
# $1 : TAG start
# $2 : TAG end
# $3 : result variable (list)
# $4 : input file
function read_between_tags ()
{
while read ROW
do
if [ "$ROW" = "$1" ]
then
I=0
while read LIST_ROW
do
if [ "$LIST_ROW" != "$2" ]
then
eval "$3[$I]="$LIST_ROW""
I=$((I+1))
else
return 0
fi
done
fi
done < "$4"
}
read_between_tags $OWN_START $OWN_END OWN file.txt
echo -e "OWN contents:\n\t ${OWN[*]}"
read_between_tags $LIST_START $LIST_END LIST file.txt
echo -e "LISTA contents:\n\t ${LIST[*]}"
È praticamente tutto nella funzione read_between_tags: dandole in pasto il tag iniziale, quello finale, una variabile nella quale salvare il contenuto (come array) e un file, legge il file finché non incontra il tag iniziale, dopodiché riempie l'array con quel che trova prima del tag finale.
Ovviamente è migliorabile (non ho pensato a utenti "bizantini"

) però fa quel che deve col file presentato come esempio.