在Ubuntu或linux中为coreutils工具包的cp和mv命令添加进度条

1、查看当前最新的coreutils版本:

http://ftp.gnu.org/gnu/coreutils/

2、安装coreutils过程

wget http://ftp.gnu.org/gnu/coreutils/coreutils-9.4.tar.xz

tar -xJf coreutils-9.4.tar.xz

cd coreutils-9.4/

对照上面的,下载对应coreutils版本的advcpmv版本。

https://github.com/jarun/advcpmv

wget https://raw.githubusercontent.com/jarun/advcpmv/master/advcpmv-0.9-9.4.patch

patch -p1 -i advcpmv-0.9-9.4.patch

./configure FORCE_UNSAFE_CONFIGURE=1

configure: creating ./config.status

config.status: creating Makefile

config.status: creating po/Makefile.in

config.status: creating gnulib-tests/Makefile

config.status: creating lib/config.h

config.status: executing depfiles commands

config.status: executing po-directories commands

config.status: creating po/POTFILES

config.status: creating po/Makefile

make

make[4]: Leaving directory '/root/coreutils-9.4/gnulib-tests'

make[3]: Leaving directory '/root/coreutils-9.4/gnulib-tests'

make[2]: Leaving directory '/root/coreutils-9.4/gnulib-tests'

make[1]: Leaving directory '/root/coreutils-9.4'
注:直接编译会出错,需要增加FORCE_UNSAFE_CONFIGURE=1 参数配置。

checking whether mknod can create fifo without root privileges... configure: error: in '/root/coreutils-9.4':

configure: error: you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check)

See 'config.log' for more details

替代当前系统命令,有必要可以先备份一下原来的,替换测试后,再将原有版本删除。

$ sudo cp src/cp /usr/local/bin/cp

$ sudo cp src/mv /usr/local/bin/mv

接着我们只需要在使用cp和mv命令的时候加上-g参数就可以显示进度条了。

为了方便起见我们可以在.bashrc文件中设置alias

alias cp='cp -ig'

alias mv='mv -ig'

至此,完成。

相关推荐
chlk12316 小时前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑16 小时前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件17 小时前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
碳基沙盒17 小时前
OpenClaw 多 Agent 配置实战指南
运维
深紫色的三北六号1 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash1 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI2 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行2 天前
Linux和window共享文件夹
linux
木心月转码ing3 天前
WSL+Cpp开发环境配置
linux
蝎子莱莱爱打怪4 天前
Centos7中一键安装K8s集群以及Rancher安装记录
运维·后端·kubernetes