shell脚本拷贝大文件显示拷贝的百分比

拷贝大文件显示百分比

#!/bin/bash
strace -q -eread cp -- "${1}" "${2}" 2>&1 \
| awk '{
    count += $NF
    if (count % 10 == 0) {
        percent = count / total_size * 100
        for (i=0;i<=percent;i++)
            printf("=");
        printf(">");
        printf ("%2.0f%%\r", percent);
    }
}
END { print "" }' total_size=$(stat -c '%s' "${1}") count=0

注:strace命令

你可能感兴趣的:(shell脚本拷贝大文件显示拷贝的百分比)