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
  • 497,756
  • 71
  • 530
  • 681
BioloItz
  • 25
  • 1
  • 5

1 Answers1

3

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,752
  • 11
  • 20