簡體   English   中英

GeekTool(UNIX)計數器前導零

[英]GeekTool (UNIX) counter leading zeros

我正在嘗試通過Mac(基於UNIX)上的GeekTool進行比賽的計時計數器,並具有以下幾點:

expr `date -j -f "%d/%m/%Y %H:%M:%S" "05/09/2012 07:41:15" "+%s"` - `date "+%s"` | awk '{ if( int( 0$1/86400 ) < 0 ) printf "" , int( 0$1/86400 ) ; if( int( 0$1/86400 ) < 0 || int( $1%86400/3600 ) < 0 ) printf "%d:" , int( $1%86400/3600 ) ; if( int( $1/86400 ) < 0 || int( $1%86400/3600 ) < 0 || int( $1%3600/60 ) < 0) printf "%d:" ,  int( $1%3600/60 ) ; if( int( $1/86400 ) < 0 || int( $1%86400/3600 ) < 0 || int( $1%3600/60 ) < 0 || $1%60 < 0 ) printf "%d" , $1%60 ; else printf "Hello!" }' | sed -E 's/-/ /' | sed -E 's/-/ /' | sed -E 's/-/ /' | sed -E 's/-/ /'

問題是,當分鍾或秒小於10時,就沒有前導零(即1:7而不是01:07)。 如何在此添加前導零,使其看起來像標准計時時鍾?

使用MS

$ date +"%H:%M:%S"
14:54:00

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM