Ik wil graag meer leren over bash scripting alleen liep ik tegen het onderstaande probleem aan. Het gaat erom dat als ik een getal invul willekeurig, moet hij vanaf het cijfer aftellen naar GO!.
Zouden jullie mij willen helpen?
1= Modify countdown such that it prompts user for a starting value, and counts down from there.
2= Write a script called countdown2 that accepts the initial value as a command-line argument. For example, the command and its output might look like the following.
#!/bin/bash
#for loop, bij deze opdracht wordt er afgeteld. Van 10 t/m GO.
generate_list ()
{
echo "10 9 8 7 6 5 4 3 2 1 GO!"
}
for getal in $(generate_list) # Let op "getal" heeft een uitgangsfunctie.
do
echo "$getal"
done
# 10
# 9
# 8
# 7
# 6
# 5
# 4
# 3
# 2
# 1
# GO!
Zouden jullie mij willen helpen?
1= Modify countdown such that it prompts user for a starting value, and counts down from there.
2= Write a script called countdown2 that accepts the initial value as a command-line argument. For example, the command and its output might look like the following.
#!/bin/bash
#for loop, bij deze opdracht wordt er afgeteld. Van 10 t/m GO.
generate_list ()
{
echo "10 9 8 7 6 5 4 3 2 1 GO!"
}
for getal in $(generate_list) # Let op "getal" heeft een uitgangsfunctie.
do
echo "$getal"
done
# 10
# 9
# 8
# 7
# 6
# 5
# 4
# 3
# 2
# 1
# GO!
[ Voor 16% gewijzigd door cvinkestijn op 09-03-2011 14:35 ]