How to show and update echo on same line

前端 未结 6 1315
陌清茗
陌清茗 2020-11-27 11:27

I have the following in Bash (In Linux)

for dir in Movies/*
do
  (cd \"$dir\" && pwd|cut -d \\/ -f5|tr -s \'\\n\' \', \' >> ../../movielist &am         


        
6条回答
  •  被撕碎了的回忆
    2020-11-27 12:24

    If I have understood well, you can get it replacing your echo with the following line:

    echo -ne "Movie $movies - $dir ADDED! \033[0K\r"
    

    Here is a small example that you can run to understand its behaviour:

    #!/bin/bash
    for pc in $(seq 1 100); do
        echo -ne "$pc%\033[0K\r"
        sleep 1
    done
    echo
    

提交回复
热议问题