×
Create a new article
Write your page title here:
We currently have 3,187 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,187Articles

    Weltraumrennen in Bash

    #!/bin/bash
    # "Weltraumrennen" in Bash - Linux Magazin 03/11 Listing 2 - S.113
    pos=40
    width=80
    
    while true; do
    read -t1 -s -n1 x
    case "$x" in
            g) pos=$(($pos - 1)) ;;
            h) pos=$(($pos +1 ));
    esac
    
    for ((i=0; i < $width; i++))
    do
            if [ $i -eq $pos ]; then
            echo -n 'V'
            elif [ $(($RANDOM % 9)) -eq 0 ]; then
            echo -n '*'
            else
            echo -n ' '
            fi
    done
    
    echo
    done
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.