&1\|awk'{count+=$NFif(count%10==0){percent=count/total_ ; 更新日期:2024/9/21 饿虎岗资源网" />

当前位置:首页 >> 脚本专栏

shell脚本实现拷贝大文件显示百分比的代码分享

复制代码 代码如下:
#!/bin/sh

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