How to add a progress bar to a shell script?

后端 未结 30 2286
情歌与酒
情歌与酒 2020-11-22 05:48

When scripting in bash or any other shell in *NIX, while running a command that will take more than a few seconds, a progress bar is needed.

For example, copying a b

30条回答
  •  旧时难觅i
    2020-11-22 06:33

    A simpler method that works on my system using the pipeview ( pv ) utility.

    srcdir=$1
    outfile=$2
    
    
    tar -Ocf - $srcdir | pv -i 1 -w 50 -berps `du -bs $srcdir | awk '{print $1}'` | 7za a -si $outfile
    

提交回复
热议问题