[Wolves] Arrays within Bash
Simon Burke
simonb at fatsportsman.eu
Thu Jul 28 12:19:35 UTC 2011
On Thu, Jul 28, 2011 at 12:55 PM, Re-LoaD <reload at brum2600.net> wrote:
> you then do what you like with the array :-
>
> for heh in "${stuffarray[@]}"
> do
> echo "---"
> echo $heh
> done
>
> :-)
>
> Re-LoaD
>
>
>
> On 28/07/2011 12:51, Re-LoaD wrote:
>>
>> not sure what you mean but will this help :---
>>
>> Cheers
>> Reload
>> ----
>> reload at orac:~$ cat myfile.txt
>> BP1_FS1='bp1_usr /usr/BP1'
>> BP1_FS2='bp1_mnt /mnt/BP1'
>> BP1_FS3='bp1_ora /oracle/BP1'
>> BP1_FS4='bp1_data /oracle/BP1/data'
>> BPA
>> HELLO
>> TEST
>> BLAH
>>
>> reload at orac:~$ cat myscript.sh
>> #!/bin/bash
>> stuffarray=(` cat myfile.txt | awk '$0~"BP1_FS" {print $0}'` )
>>
>> echo ${stuffarray[@]}
>>
>>
>>
>> reload at orac:~$ ./myscript.sh
>> BP1_FS1='bp1_usr /usr/BP1' BP1_FS2='bp1_mnt /mnt/BP1' BP1_FS3='bp1_ora
>> /oracle/BP1' BP1_FS4='bp1_data /oracle/BP1/data'
>> reload at orac:~$
Thank you for that. I decided to cheat in the end and reformat my
include to go from:
Var1=blah
Var2=meh
Var3=foo
To just defining them directly into arrays via comma separated lists.
Hopefully it wont be too difficult for the end users to add things to
the end of a list.
declare -a ARRAY=( foo,bar,meh,blah )
It's been a long while since I've had to write anything so I am very rusty.
More information about the Wolves
mailing list