[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] sintax de array em script
From: |
Andrea VB |
Subject: |
Re: [shell-script] sintax de array em script |
Date: |
Tue, 17 Feb 2009 16:06:32 -0300 |
2009/2/17 Fabiano Caixeta Duarte <address@hidden>:
> 2009/2/17 sergiolinux1 <address@hidden>:
>> Olá lista,
>>
>> Estou tendo dificuldades para utilizar arrays "dentro" do shell script.
>>
>> Se eu utilizar esses comandos na linha de comando funciona beleza,
>> ex. $array=( zero one two three four five ) e $echo ${area[2]}
>> como está na pagina abaixo,
>> http://tldp.org/LDP/abs/html/arrays.html
>>
>> Mas se eu utilizar dentro do shell dá error como 2: Syntax error: "("
>> unexpected ou 9: Bad substitution.
>>
>> Se eu copiar e colar o exemplo da pagina em um shell e rodar ele
>> também da erro.
>>
>> Alguem pode me explicar onde estou errando?
>>
>> Obrigado a todos.
>
> Aparentemente não está errando.
>
> cat teste.sh
>
> array=( zero one two three four five )
> echo ${array[2]}
>
> ./teste.sh
> two
>
> Ou seja, está certo e funcionou :P
Na mensagem original tava "$array=( zero one two three four five )" e
não "array=( zero one two three four five )". Por isso que pra vc deu
certo e pra ele não. :)
--
Andrea VB
Please, don't CC me when replying to me on the lists, and use BCC when
sending mass e-mails.