> For the complete documentation index, see [llms.txt](https://kawsing.gitbook.io/opensystem/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kawsing.gitbook.io/opensystem/andoid-shou-ji/untitled-4/shell-script/shu-wei-shi-zhong.md).

# 數位時鐘（while迴圈）

### 執行以下指令,看看顯示效果

date +'%Y %b %e 星期%a%n%I:%M:%S %p'

使用 while loop​ 製作時鐘(while 條件;do ....;done)

```
date +'%Y %b %e 星期%a%n%I:%M:%S %p'
while sleep 1
do
    #始終保持游標向上移動兩行
    tput cuu 2
    #顯示時間
    date +'%Y %b %e 星期%a%n%I:%M:%S %p'
done

```
