- [Narrator] Hello again and welcome
to the last video of section two,
making commands quicker by running parallel processes.
In the previous video we learned about
automating interactive input.
In this video we'll see how we can make
our commands run faster.
Computing power has increased a lot
over the last couple of years.
However, this is not just because of having processes
with higher clock cycles.
The thing that makes modern processes faster
is multiple calls.
What this means to the user
is in a single hardware processor
there are multiple logical processes.
However, the multiple calls are useless
unless the software makes use of them.
For example, if you have a program that
does huge calculations it will only run on one of the calls
the others will sit idle.
The software has to be aware and take advantage
of the multiple calls if you want it to be faster.
Let's see how to do it.
Let's take an example of the md5sum command
that we discussed in the previous section.
This command is CPU intensive
as it has to perform a calculation.
Now if we have more than one file
we want to generate a checksum for
we can run multiple instances of md5sum
using a script like this.
When we run this we get the following output.
The output will be the same
as running the following command.
However, as the md5sum commands ran simultaneously,
you'll get results quicker if you have
a multi-call processor.
You can verify this using the time command.
We exploit the bash operand ampersand
which instructs the shell to send the command
to the background and continue with the script.
However, this means that our script will exit
as soon as the loop completes while the md5sum processes
are still running in the background.
To prevent this, we get the PIDs of the process
using $! which in bash holds the PID
of the last background process.
We append these PIDs to an array
and then use the wait command
to wait for these processes to finish.
Also, in this video we have seen how to make commands
quicker by running parallel processes.
This video concludes the second section of this course.
We first learned about concatenating with cat
and then we moved on to recording
and playing back of digital sessions.
After that we have seen about finding files
and file listing.
Then we moved on to playing with XOGs.
Also we've seen how to translate with TR.
Then we've learned about the checksum and verification.
We then learned about cryptographic tools and hashes.
We've also learned how to sort unique and duplicates.
Then we have seen about temporary file naming
and random numbers.
Then we have seen how to split files and data.
We then moved on to a topic slicing filenames
based on extension.
Then we learned how to rename and move files in bulk.
We've also seen spell check and dictionary manipulation
and then moved on to automating interactive input.
Finally, we've seen about making commands quicker
by running parallel processes.
All the following videos in all the next sections
we will see how to handle operations or properties
relating to files.
So the next section, we'll discuss about file in, file out.