Re: bash increment in a given way

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/11/2010 10:19 AM, Genes MailLists wrote:
> On 12/11/2010 09:34 AM, S Mathias wrote:
> 
>> but what's the "magic" for this? :
>>
>> $ MAGIC; do echo "Welcome $i times"; done
>> Welcome 0 times
>> Welcome 1 times
>> Welcome 4 times
>> Welcome 5 times
>> Welcome 8 times
>> Welcome 9 times
>> $
>>
>> thanks:\
>>
>>
> 
>   Probably lots of ways to do this here's one:

  Perhaps you have a short list rather than an arithmetic expression -
in that case an array would work:

  list=( 0 1 4 5 8 dogs peanut 11 )
  num=${#list[*]}
  typeset -i i
  i=0
  while (( i <= num ))
  do
     echo hi ${list[i]}
     i="i+1"
  done
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux