Debian Codegraph @

ex53.sh

raw symbols SCIP
1 #!/bin/bash
2 # Using "seq"
3
4 echo
5
6 for a in `seq 80` # or for a in $( seq 80 )
7 # Same as for a in 1 2 3 4 5 ... 80 (saves much typing!).
8 # May also use 'jot' (if present on system).
9 do
10 echo -n "$a "
11 done # 1 2 3 4 5 ... 80
12 # Example of using the output of a command to generate
13 # the [list] in a "for" loop.
14
15 echo; echo
16
17
18 COUNT=80 # Yes, 'seq' also accepts a replaceable parameter.
19
20 for a in `seq $COUNT` # or for a in $( seq $COUNT )
21 do
22 echo -n "$a "
23 done # 1 2 3 4 5 ... 80
24
25 echo; echo
26
27 BEGIN=75
28 END=80
29
30 for a in `seq $BEGIN $END`
31 # Giving "seq" two arguments starts the count at the first one,
32 #+ and continues until it reaches the second.
33 do
34 echo -n "$a "
35 done # 75 76 77 78 79 80
36
37 echo; echo
38
39 BEGIN=45
40 INTERVAL=5
41 END=80
42
43 for a in `seq $BEGIN $INTERVAL $END`
44 # Giving "seq" three arguments starts the count at the first one,
45 #+ uses the second for a step interval,
46 #+ and continues until it reaches the third.
47 do
48 echo -n "$a "
49 done # 45 50 55 60 65 70 75 80
50
51 echo; echo
52
53 exit 0