dimanche 28 mars 2021

print even and odd numbers

now my code looks like this

!/bin/bash

read INPUT
for number in $(seq 1 $INPUT); do
        if [ $((number%2)) -eq 0 ]
        else [ $((number%2)) -eq 1 ]; then
           echo $number
        fi
done

but then I get the next error

./script.sh: line 6: syntax error near unexpected token `else'
./script.sh: line 6: `        else [ $((number%2)) -eq 1 ]; then'

Aucun commentaire:

Enregistrer un commentaire