for i in [0-9a-f]; do
/path/to/do/stuff "num_$i" &
done
I want to run the following commands:
/path/to/do/stuff num_0 &
/path/to/do/stuff num_1 &
/path/to/do/stuff num_2 &
.....
/path/to/do/stuff num_f &
many thanks,
lihao
> Is there an easy way to loop through hex-decimals i.e. [0-9a-z] in a
> for loop, the following is not working:
>
> for i in [0-9a-f]; do
for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do
> Is there an easy way to loop through hex-decimals i.e. [0-9a-z] in a
> for loop, the following is not working:
>
> for i in [0-9a-f]; do
> /path/to/do/stuff "num_$i" &
> done
$ $0 --version
GNU bash, version 3.2.39(1)-release (i686-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
$ for z in {0..9} {a..f};do echo $z\&;done
0&
1&
2&
3&
4&
5&
6&
7&
8&
9&
a&
b&
c&
d&
e&
f&
exactly what I am looking for, many thanks. :-)
lihao
awk 'BEGIN{ for(i = 0; i < 0x10; i++)
printf "num_%x\n", i}' | xargs -n1 /path/to/do/stuff
--
Stéphane
i=0
while [ $i -lt 16 ]; do
h=$(printf "%x" "$i")
do_stuff "num_$h" &
i=$((i+1))
done