When using the cp command to copy large files in Linux, it is usually impossible to view the copy progress in real time. This situation may make people feel anxious because there is no way to know the progress of the copy. However, you can use some techniques to add a visual progress bar to the cp command so that users can clearly see the progress of the copy.
We use open source projects: advcpmv
The github address is:
https://github.com/jarun/advcpmv
You can directly use the following command to compile and install (non-root) and execute it in the Linux environment. I use the CentOS operating system to demonstrate here:
curl https://raw.githubusercontent.com/jarun/advcpmv/master/install.sh --create-dirs -o ./advcpmv/install.sh && (cd advcpmv && sh install.sh)
If you need to execute it under the root user, add environment variables before the downloaded installation script
FORCE_UNSAFE_CONFIGURE=1 ./install.sh
After the script ends, it will look like the following picture:
# 显示当前目录下已经编译好的文件 cd advcpmv && ls
Use the following command to install and use:
sudo mv ./advcp /usr/local/bin/advcp sudo mv ./advmv /usr/local/bin/advmv
Test copy:
advcp -g 源文件 目标位置
Found that the progress bar has appeared successfully:
If you want to directly replace the original cp and mv commands, you can use aliases:
echo alias cp '/usr/local/bin/advcp -g' >> ~/.bashrc echo alias mv '/usr/local/bin/advmv -g' >> ~/.bashrc
If there is a need to frequently copy large files in the company, this command can be integrated into the Linux system command of the production environment for direct use.
The above is the detailed content of How to display the progress bar in linux cp command. For more information, please follow other related articles on the PHP Chinese website!