Search

Command cp with Progress Bar

Useful for tracking the progress of copies via the command line.


Command cp with Progress Bar

The cp command is part of GNU CoreUtils and one of the features that a lot of people wanted to be implemented would be a progress bar, but as this hasn’t happened yet, a programmer created a patch and made it available on GitHub that can be implemented on GNU CoreUtils and you use it! Installation

The procedure is very simple, just follow the steps:

  • 1. First of all make sure you have the software building tools on your computer, example:
sudo apt install gcc g++ make build-essential

  • 2. Download GNU CoreUtils
wget http://ftp.gnu.org/gnu/coreutils/coreutils-8.32.tar.xz
  • 3. Decompress
tar xvJf coreutils-8.32.tar.xz
  • 4. Enter the directory and then download the patch
cd coreutils-8.32/
wget https://raw.githubusercontent.com/jarun/advcpmv/master/advcpmv-0.8-8.32.patch
  • 5. Apply the patch
patch -p1 -i advcpmv-0.8-8.32.patch
  • 6. Compile
./configure
make

The binary will be created in the src directory, ie coreutils-8.32/src/cp, you can move it to replace the original cp with the command: sudo cp src/cp $(which cp) (cp copies cp 😃).

Or create an alias (I think most recommended):

mkdir -p ~/.local/bin
cp src/cp ~/.local/bin/cp
echo 'alias cp="${HOME}/.local/bin/cp"' >> ~/.bashrc
exec $SHELL

And test, example:

Use the --progress-bar parameter

cp --progress-bar Documents/Fedora-Workstation-Live-x86_64-33-1.2.iso .
copying at 111,2 MiB/s (about 0h 0m 23s remaining)
Documents/Fedora-Workstation-Live-x86_64-33-1.2.iso                   340,9 MiB /   1,9 GiB
[===============================>

If you want to avoid using this parameter, create the alias with the parameter, example:

vim ~/.vimrc and leave the alias in this file like this:

alias cp="${HOME}/.local/bin/cp --progress-bar"

Close, run source ~/.bashrc and test without the parameter, it will be included automatically:

cp Documentos/Fedora-Workstation-Live-x85_64-33-1.2.iso .
copying at 111,2 MiB/s (about 0h 0m 23s remaining)
Documentos/Fedora-Workstation-Live-x86_64-33-1.2.iso                   340,9 MiB /   1,9 GiB
[===============================>

The same can be used for the mv command which will also be in src, however, give preference to the -g parameter instead of the --progress-bar, it is simpler! But honestly, I don’t see any use in using this in mv because things are moved so fast that you don’t even need it.

That’s it for today!


gnu linux


Share



Comments