- #!/bin/bash
- #Description: A shell script to copy parameter1 to parameter2 and Display a progress bar
- #Author:Jacob
- #Version:0.1 beta
- # Read the parameter for copy,$1 is source dir and $2 is destination dir
- dir=$1/*
- des=$2
- # Test the destination dirctory whether exists
- [ -d $des ] && echo "Dir Exist" && exit 1
- # Create the destination dirctory
- mkdir $des
- # Set counter, it will auto increase to the number of source file
- i=0
- # Count the number of source file
- n=`echo $1/* |wc -w`
- for file in `echo $dir`
- do
- # Calculate progress
- percent=$((100*(++i)/n))
- cat <<EOF
- XXX
- $percent
- Copying file $file ...
- XXX
- EOF
- /bin/cp -r $file $des &>/dev/null
- done | dialog --title "Copy" --gauge "files" 6 70
- clear
shell之图形进度条
最新推荐文章于 2024-05-29 11:38:17 发布