Home > Computer Tutorials > Computer Knowledge > How to display the progress bar in linux cp command

How to display the progress bar in linux cp command

王林
Release: 2024-03-23 20:41:44
forward
1579 people have browsed it

1. Background

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.

2. Compile

We use open source projects: advcpmv

The github address is:

https://github.com/jarun/advcpmv
Copy after login

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)
Copy after login

linux cp命令怎么显示进度条

If you need to execute it under the root user, add environment variables before the downloaded installation script

FORCE_UNSAFE_CONFIGURE=1 ./install.sh
Copy after login

After the script ends, it will look like the following picture:

linux cp命令怎么显示进度条

# 显示当前目录下已经编译好的文件
cd advcpmv && ls
Copy after login

linux cp命令怎么显示进度条

3. Installation and use

Use the following command to install and use:

sudo mv ./advcp /usr/local/bin/advcp
sudo mv ./advmv /usr/local/bin/advmv
Copy after login

Test copy:

advcp -g 源文件 目标位置
Copy after login

Found that the progress bar has appeared successfully:

linux cp命令怎么显示进度条

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
Copy after login

4. Summary

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!

Related labels:
source:mryunwei.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template