Fatmawati Ahmad Zaenuri / Shutterstock.com

Instead of Flying Blindly, Use Linux Commands pv and progress to track the progress of the command. These utilities will give you progress bars for commands that don’t normally have them. You will also see the estimated time to completion.

If you’re on a long-haul flight without video screens in your seatbacks, it’s not easy to know how far you’ve traveled. You know when you took off. You know how long the flight will take. But how do you know you’re on the right track, on time, or way behind schedule? If you don’t want to watch a movie in flight, you can usually switch the video screen to show a map with your aircraft’s location on it. You also get some stats like expected time of arrival (ETA), which is great.

Running a command from a terminal window can sometimes feel like a long flight without a video screen. You have nothing to indicate if everything is fine, or the process is hung, or how close it is to completion. The blinking cursor is not very informative.

Teams pv and progress give you some stats and a little visual feedback. You can see how close the process is to completion. This means you get an ETA for your running processes. Compared to looking at the cursor, it wins hands down.

PV installation

You must install pv .

to install pv on Ubuntu, use this command:

  sudo apt-get установить pv 

sudo apt-get install pv in terminal window

to install pv on Fedora, use this command:

  sudo dnf установить pv 

sudo dnf install pv in terminal window

to install pv on Manjaro, use this command:

  Судо Пакман -Сю П.В. 

sudo pacman -su pv in a terminal window

Using PV

pv denotes the viewer’s trumpet. The pipeline must be involved somewhere in the team. Here is an example where we pass the ISO image through zip to create a compressed ISO zip file.

In order to slow down the commands enough to take a screenshot, some of the files in the examples used for this article were saved on an old slow external USB drive called SILVERXHD.

  pv /media/dave/SILVERXHD/gparted-live-1.0.0-1-amd64.iso |  zip> gparted.zip 

pv /media/dave/SILVERXHD/gparted-live-1.0.0-1-amd64.iso |  zip > gparted.zip in a terminal window» width=»646″ height=»77″ src=»https://gadgetshelp.com/wp-content/uploads/images/htg/content/uploads/2019/07/progress_6.png»></p>
<p><noscript><img class=

Information is displayed from left to right:

  • The data has been transferred so far.
  • Time has gone far.
  • Data transfer rate (bandwidth).
  • Progress bar and percentage completed figure.
  • Estimated time remaining to completion (ETA).

Copying a file with pv

To copy a file with output from pv use this command:

  pv /media/dave/SILVERXHD/gparted-live-1.0.0-1-amd64.iso> gparted.iso 

pv /media/dave/SILVERXHD/gparted-live-1.0.0-1-amd64.iso |  gparted.iso in terminal window

We get a progress report as the file is copied.

copying a file with pv in a terminal window

Copying multiple files using PV

To copy multiple files and folders using pv we need to use a little trick. We use tar to move files for us.

  tar -c help-files / |  PV |  tar -x -C Документы / 

tar -c help-files / |  PV |  tar -x -C Documents / in a terminal window

tar -c help-files/ part of the command indicates tar create ( -c ) file archive in the help-files folder. It comes through pv so we can see progress. It is then passed back to tar for the last part of the command. The archive is extracted ( -x ) and the directory is changed ( -C ) on Documents before extracting.

So, the files and folders that are in the reference files are copied to the «Documents» folder with progress displayed.

copying files with pv and tar in a terminal window

This time the output is slightly different.

We do not receive an ETA. The progress bar now displays a moving bar. This shows that the process is active, but it does not grow from left to right like a traditional progress bar. pv limited to displaying the information it can extract from the process that is being piped.

Using pv and tar to create an archive

Copying files using pv and tar doesn’t leave us with an archive file. Tar creates a kind of «virtual» archive that is fed back to tar to extract files. If our goal is to copy files, this has been achieved. But what if we want to create an archive file?

We can still use tar to create an archive file and get a progress report from pv . Options used with tar : -c (create archive) -z (compress with gzip) and -f (archive file name).

Please note that we are using - as the filename, which makes tar use stdout and write its output to a terminal window. We do not see this output because it is passed through pv .

The actual name of the archive will be the name of the file where we will pipe the output from pv . In this case it is «help-files.tgz».

  tar -czf - ./help-files/ |  pv> help-files.tgz 

tar -czf - ./help-files/ |  pv> help-files.tgz in a terminal window» width=»646″ height=»57″ src=»https://gadgetshelp.com/wp-content/uploads/images/htg/content/uploads/2019/07/xprogress_12.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ ri+cp+md.ic.GUtmeQ—vd.png»></p>
<p><noscript><img class=

RELATED: How to compress and extract files using the tar command in Linux

PV display options

There are a number of options that you can use with pv to change the details of your report.

If you use any of these options, all other options are disabled. So if you want to use three display options, you need to specify those three options.

Usage pv without any parameters is similar to using parameters -pterb .

  • -p : show percent execution. This is the progress bar and the percentage of the completed figure.
  • -t : show past time .
  • -e : display ETA .
  • -r : show speed data transmission.
  • -b : display quantity bytes (data transferred so far).
  • -n : display percentage as whole number . This prints the percentage completed as an integer digit, with each new update on a new line.

Let’s repeat the last command and pass the option -p (percent completed) in pv .

  tar -czf - ./help-files/ |  pv - p> help-files.tgz 

tar -czf - ./help-files/ |  pv - p>help-files.tgz in terminal window» width=»646″ height=»57″ src=»https://gadgetshelp.com/wp-content/uploads/images/htg/content/uploads/2019/07/progress_14.png»></p>
<p><noscript><img class=

Using PV with WC

We can use pv to transfer a text file (or files) to wc . Then wc will count carriage returns, characters and words, and pv provide us with a progress report.

Here we send all the «.page» files from the help-files directory to wc .

pv ./help-files/*.page |  toilet in the terminal window

When wc finishes, we’ll see the number of carriage returns (lines), characters, and words from all the «.page» files in the help-files folder.

output from pv and wc in terminal window

Setting the progress command

Team progress gives the same useful information as pv but it works with a specific set of Linux commands.

to install progress on Ubuntu, use this command:

  sudo apt-get прогресс установки 

sudo apt-get installation progress in terminal window

to install progress on Fedora, use this command:

  прогресс установки sudo dnf 

sudo dnf installation progress in terminal widow

to install progress in Manjaro, use this command:

  Судо Пакман -Сю прогресс 

sudo pacman -Shu progress in terminal window

Progress commands works with

Typing progress in the terminal window and pressing Enter, you will get a list of commands with which it works progress .

  прогресс 

run command output in terminal window

Using progress with pipes

There are two methods we can use to monitor commands with progress . The first is the use of pipes.

Team tar is in the list of supported commands that can be tracked progress so let’s use tar .

We will use options -c (create archive) -z (compress with gzip) and -f (File name). We are going to create a compressed archive of everything in the help files folder, and this archive will be called «help.tgz».

We connect it to progress and use the option -m (monitor) to progress continued to report on the process until its completion.

  tar -czf help.tgz ./help-files/ |  прогресс -м 

tar -czf help.tgz ./help-files/ |  Progress -m in terminal window

The terminal window will show the progress of the command tar when creating an archive.

tar commands to monitor progress in a terminal window

As each file is processed, it contains the following information:

You might be surprised to see the second set of data. This first dataset is for tar . Second for gzip . tar causes gzip to perform compression. Because the gzip is in the list of supported commands, reports on its execution.

Using progress in continuous monitoring mode

you can use progress in continuous real-time monitoring mode using the -M (monitor) option.

Enter the following command in a terminal window:

  прогресс -М 

Progress -M in terminal window

progress will report that no commands have been run to monitor it. But you won’t get back to the command line. progress waits for a command that it can monitor to run. It will then automatically start reporting on it.

progress while waiting for command to run in terminal window

In another terminal window, enter the command that is in the list of commands that can monitor progress.

We are going to use cat . Commands that are too fast will not be registered with progress so we’ll list the contents of a very long text file.

  cat words.page 

cat words.page in terminal window

In a terminal window with progress in it you will see statistics for the team cat how it is executed and works towards completion.

progress report on cat in terminal window

When cat ends listing, progress file returns to the pending state.

Whenever one of the teams she can report performs a significant task, progress automatically tracks it and reports it.

It’s pretty neat.

100% completed

Don’t think about how the long running command works and take a break from contemplating the cursor with pv and progress .

Похожие записи