bash script, erase previous line?

前端 未结 6 1271
暗喜
暗喜 2021-01-31 10:31

In lots of Linux programs, like curl, wget, and anything with a progress meter, they have the bottom line constantly update, every certain amount of time. How do I do that in a

6条回答
  •  深忆病人
    2021-01-31 11:07

    Small variation on linuts' code sample to move the cursor not to the beginning, but the end of the current line.

    {
      for pc in {1..100}; do
        #echo -ne "$pc%\033[0K\r"
        echo -ne "\r\033[0K${pc}%"
        sleep 1
      done
      echo
    }
    

提交回复
热议问题