在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'

至此,完成。

相关推荐
Kookoos25 分钟前
Dynamics 365 Finance + Power Automate 自动化凭证审核
运维·自动化·dynamics 365·power automate
apocelipes3 小时前
Linux c 运行时获取动态库所在路径
linux·c语言·linux编程
努力学习的小廉4 小时前
深入了解linux系统—— 进程池
linux·运维·服务器
秃头菜狗4 小时前
各个主要目录的功能 / Linux 常见指令
linux·运维·服务器
2301_793102494 小时前
Linux——MySql数据库
linux·数据库
jiunian_cn6 小时前
【Linux】centos软件安装
linux·运维·centos
藥瓿亭6 小时前
K8S认证|CKS题库+答案| 6. 创建 Secret
运维·ubuntu·docker·云原生·容器·kubernetes·cks
程序员JerrySUN6 小时前
[特殊字符] 深入理解 Linux 内核进程管理:架构、核心函数与调度机制
java·linux·架构
孤寂大仙v6 小时前
【计算机网络】非阻塞IO——select实现多路转接
linux·计算机网络
2302_809798326 小时前
【JavaWeb】Docker项目部署
java·运维·后端·青少年编程·docker·容器