I'm trying to write a script the generates a template file for Pashua (a perl script for creating GUI on osx)
I want to crate an instance for each item in the array, so the ideal output would be:
AB1.type = openbrowser
AB1.label = Choose a master playlist file
AB1.width=310
AB1.tooltip = Blabla filesystem browser
AB2.type = openbrowser
AB2.label = Choose a master playlist file
AB2.width=310
AB2.tooltip = Blabla filesystem browser
...and so on for the rest of the array:
What I am using to write to the text file at the moment is:
count=1
saveIFS="$IFS"
IFS=$'\n'
array=($(<TEST.txt))
IFS="$saveIFS"
for i in "${array[@]}"; do declare AD$count="$i"; ((count++)); done
for i in "${array[@]}"; do echo "AD$count".type = openbrowser "AD$count".label = Choose a master playlist file \n "AD$count".width=310 \n "AD$count".tooltip = Blabla filesystem browser \n" >> long.txt; done
However \n doesn't produce a newline in the text file, and I am pretty sure there is a alot nicer way todo this, ideas?