前言:在Linux默认CP MV命令在传输是没有显示进度,在一些场景下又想查看传输速度,下面通过安装两个命令来实现CP MV命令在传输文件时显示进度。
第一个使用progress命令
Centos7安装progress命令
[root@localhost aihuidi]# wget http://mirrors.sohu.com/centos/7/infra/x86_64/infra-common/Packages/p/progress-0.13-1.el7.x86_64.rpm
[root@localhost aihuidi]# rpm -ivh progress-0.13-1.el7.x86_64.rpm
[root@localhost ~]# cp meepo-install_20230208_v1.tar.gz /tmp/
查看传输进度,新开终端执行下面任意一条查看
[root@localhost ~]# progress -M -w
[root@localhost ~]# watch -n1 progress -w
第二个使用advcpmv
下载
https://github.com/jarun/advcpmv
使用脚本一键安装
vi install.sh
#!/bin/sh
set -e
ADVCPMV_VERSION=${1:-0.9}
CORE_UTILS_VERSION=${2:-9.1}
curl -LO http://ftp.gnu.org/gnu/coreutils/coreutils-$CORE_UTILS_VERSION.tar.xz
tar xvJf coreutils-$CORE_UTILS_VERSION.tar.xz
yum -y install patch
yum install binutils -y
yum install gcc gcc-devel gcc-c++ -y
rm coreutils-$CORE_UTILS_VERSION.tar.xz
(
cd coreutils-$CORE_UTILS_VERSION/
curl -LO https://raw.githubusercontent.com/jarun/advcpmv/master/advcpmv-$ADVCPMV_VERSION-$CORE_UTILS_VERSION.patch
patch -p1 -i advcpmv-$ADVCPMV_VERSION-$CORE_UTILS_VERSION.patch
export FORCE_UNSAFE_CONFIGURE=1
./configure
make
cp ./src/cp ../advcp
cp ./src/mv ../advmv
)
rm -rf coreutils-$CORE_UTILS_VERSION
遇到的问题
1、
-bash: patch: command not found
解决方法:
yum -y install patch
2、
configure: error: in `/root/aihuidi/coreutils-9.1':
configure: error: C compiler cannot create executables
解决方法:
[root@localhost coreutils-9.1]# yum install binutils -y
[root@localhost ~]# yum install gcc gcc-devel gcc-c++ -y
3、
checking whether mknod can create fifo without root privileges... configure: error: in `/root/aihuidi/coreutils-9.1':
configure: error: you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check)
解决方法:
[root@localhost coreutils-9.1]# echo "export set FORCE_UNSAFE_CONFIGURE=1" >> /etc/profile
[root@localhost coreutils-9.1]# source /etc/profile
[root@localhost coreutils-9.1]# echo "export set FORCE_UNSAFE_CONFIGURE=1" >> ~/profile
[root@localhost coreutils-9.1]# source ~/profile
查看传输进度
[root@localhost aihuidi]# ./advcp -g /root/meepo-install_20221207_v1.tar.gz /tmp/