1
echo "Enter the current time: "

read h m s

s = `expr $n + 1`

if [ $n -eq 60 ]; then

    s = 0
    m = `expr $m + 1`

    if [ $m -eq 60 ]; then

        m = 0
        h = `expr $h + 1`

        if [ $h -eq 24 ]; then
             h = 0
        fi
    fi
fi

echo "The time after one second is $h $m $n"
chepner
  • 446,329
  • 63
  • 468
  • 610
BioloItz
  • 25
  • 1
  • 5

1 Answers1

2

If you type s = 0 in a bash prompt, you will get bash: s: command not found.

The correct way to assign a variable in bash is s=0 without the spaces.

LobsterBaz
  • 1,456
  • 10
  • 18