在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

make4: Leaving directory '/root/coreutils-9.4/gnulib-tests'

make3: Leaving directory '/root/coreutils-9.4/gnulib-tests'

make2: Leaving directory '/root/coreutils-9.4/gnulib-tests'

make1: 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'

至此,完成。

相关推荐
程序员-Benothing18 小时前
Linux安全加固指南:账号、权限、服务、审计基线
linux·运维·安全
Mininglamp_271819 小时前
接口调用 vs 屏幕理解:两种 GUI 自动化架构的技术取舍
运维·架构·自动化
Cry丶19 小时前
ubuntu安装vsftpd
服务器·网络·ubuntu
爱喝水的鱼丶21 小时前
SAP-ABAP:ECC→S/4HANA ABAP 迁移升级指南——程序改造、语法兼容与性能优化 导语
运维·开发语言·性能优化·sap·abap·经验交流·开发交流
木子欢儿21 小时前
openconnect Linux客户端安装 以及开机自启和登录
linux·运维·服务器
..Dauntless..1 天前
【Linux】文件系统(一)
linux·运维·服务器
天空属于哈夫克31 天前
企业微信API二次开发 赋能私域运营自动化
运维·自动化·企业微信
天远API1 天前
零信任架构实战:基于天远运营商二要素V即时版构建自动化分时租赁出行会员身份一致性审核网关
运维·人工智能·架构·自动化
程序员-King.1 天前
【ROS1】Noetic 开发工作流程与常用命令
c++·ubuntu·ros
极光通讯1 天前
液冷服务器对内存和SSD的适配要求:高密度部署下的散热与信号完整性
运维·服务器