简体   繁体   English

Linux bash Timer

[英]Linux bash Timer

Ok, stupid newbie question here. 好的,愚蠢的新手问题在这里。 I thought I was making a countdown timer. 我以为我正在倒计时器。 This is supposed to count down from 5 and once it is at 0 then execute the echo "time is up clown" then end. 这应该从5倒计时,一旦它在0,然后执行回声“时间到了小丑”然后结束。 What am I doing wrong here? 我在这做错了什么?

seconds=5
date1=$((`date +%s` + $seconds)); 
while [ "$date1" -ne `date +%s` ]; do 
  if (!$date1 -lt ((`date +%s` + $seconds)+1)); then
     echo "time is up clown";
  break;
  fi;
  echo -ne "$(date -u --date @$(($date1 - `date +%s` )) +%H:%M:%S)\r";
done
#!/bin/bash
SECS=5
while [[ 0 -ne $SECS ]]; do
    echo "$SECS.."
    sleep 1
    SECS=$[$SECS-1]
done
echo "Time is up, clown."

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM