Interesting usage of the PV command with echo
The pv command therefore performs interestly when use with the echo command. The fascinating part is when used in bash scripting.
In this tutorial we will learn how to use the pv command with echo.
Install pv
On Debian, Ubuntu
$ sudo apt-get install pv
On Fedora, Redhat, Centos
$sudo yum install epel-release -y
$sudo yum install pv -y
Usage with echo
$man pv
Let find out the manual on the command. With echo we will focus on the use of q and L options The -q (--quiet) option will suppress the output but its used with the -L option to limit the output by byte second. Run man pv
$ echo "I love linux"
When echo is used without the pv command it just print out the text on the screen
Now let us pipe the output to the pv command.
$ echo "I love linux" | pv -qL 7.
The number indicates the byte it should print per second. So in the above example, it will print 7 bytes per second. The lower the number the slower the pv command print the output of echo.
Below is a play scripts that runs to welcome a new team member in our company. Run the below command to clone my scripts repository from github
$ git clone https://github.com/Nobleaxis/Scripts.git
Comments
Post a Comment