Repeat command automatically in Linux

前端 未结 13 1667
滥情空心
滥情空心 2020-12-04 04:54

Is it possible in Linux command line to have a command repeat every n seconds?

Say, I have an import running, and I am doing

ls -l
         


        
13条回答
  •  自闭症患者
    2020-12-04 05:20

    sleep already returns 0. As such, I'm using:

    while sleep 3 ; do ls -l ; done
    

    This is a tiny bit shorter than mikhail's solution. A minor drawback is that it sleeps before running the target command for the first time.

提交回复
热议问题