It's ok, that i can use this, when i want an incrementing sequence, in a given way:
# {START..END..INCREMENT}
$ for i in {0..10..2}; do echo "Welcome $i times"; done
Welcome 0 times
Welcome 2 times
Welcome 4 times
Welcome 6 times
Welcome 8 times
Welcome 10 times
$
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:
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
12-11-2010, 01:34 PM
S Mathias
bash increment in a given way
It's ok, that i can use this, when i want an incrementing sequence, in a given way:
# {START..END..INCREMENT}
$ for i in {0..10..2}; do echo "Welcome $i times"; done
Welcome 0 times
Welcome 2 times
Welcome 4 times
Welcome 6 times
Welcome 8 times
Welcome 10 times
$
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:
--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
12-11-2010, 01:34 PM
S Mathias
bash increment in a given way
It's ok, that i can use this, when i want an incrementing sequence, in a given way:
# {START..END..INCREMENT}
$ for i in {0..10..2}; do echo "Welcome $i times"; done
Welcome 0 times
Welcome 2 times
Welcome 4 times
Welcome 6 times
Welcome 8 times
Welcome 10 times
$
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:
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
12-11-2010, 01:41 PM
Stephen Harris
bash increment in a given way
On Sat, Dec 11, 2010 at 06:34:25AM -0800, S Mathias wrote:
> # {START..END..INCREMENT}
> $ for i in {0..10..2}; do echo "Welcome $i times"; done
> 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
You might just have to hard-code the sequence:
for i in 0 1 4 5 8 9; do ....
--
rgds
Stephen
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
12-11-2010, 01:53 PM
Markus Schönhaber
bash increment in a given way
11.12.2010 15:34, S Mathias:
> 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
> $
for i in 0 1 4 5 8 9; do echo "Welcome $i times"; done
--
Regards
mks
--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
12-11-2010, 02:03 PM
Athmane Madjoudj
bash increment in a given way
On 12/11/2010 03:41 PM, Stephen Harris wrote:
> On Sat, Dec 11, 2010 at 06:34:25AM -0800, S Mathias wrote:
> You might just have to hard-code the sequence:
>
> for i in 0 1 4 5 8 9; do ....
>
You can use seq (see: man seq)
for i in `seq FIRST INCREMENT LAST` ; do
echo $i
done;
--
Athmane Madjoudj
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
12-11-2010, 02:19 PM
Genes MailLists
bash increment in a given way
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:
WeirdIncr () {
typeset -i j
typeset -i z
j=$1
z=$(expr $j % 2)
if (( z == 0 )) ; then
j="j+1"
else
j="j+3"
fi
echo $j
}
typeset -i i
let i=0
while (( i < 10 ))
do
echo "Hi $i"
i=$(WeirdIncr $i)
done
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
12-11-2010, 02:40 PM
Chris Jackson
bash increment in a given way
S Mathias wrote:
> $ 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:
for i in 0 1 4 5 8 9; do "elcome $i times"; done
--
Chris Jackson
Shadowcat Systems Ltd.
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4D039B75.1040908@shadowcat.co.uk">http://lists.debian.org/4D039B75.1040908@shadowcat.co.uk
> 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
for i in 0 1 4 5 8 9; do echo "Welcome $i times"; done
Chris
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: o8jct7xnuh.ln2@news.roaima.co.uk">http://lists.debian.org/o8jct7xnuh.ln2@news.roaima.co.uk
12-11-2010, 03:05 PM
"Mihai T. Lazarescu"
bash increment in a given way
On 12/11/2010 03:41 PM, Stephen Harris wrote:
> On Sat, Dec 11, 2010 at 06:34:25AM -0800, S Mathias wrote:
> You might just have to hard-code the sequence:
>
> for i in 0 1 4 5 8 9; do ....
This outputs:
for i in $(seq 0 4 16); do seq $i 1 $i+1; done
0
1
4
5
8
9
12
13
16
17
Mihai
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos