GNU Parallel: do more things simultaneously in the terminal

GNU Parallel: capture

If you do a lot of work from the command line, you may be interested in some projects like tmux, among others. But today we are going to introduce you GNU Parallel in case you didn't know him. With it you can do more things at the same time simultaneously, turning your console into a multitasking center to perform operations more efficiently and quickly. All thanks to the functionalities that GNU Parallel allows to execute tasks in parallel.

GNU Parallel will allow you to get more out of your CPU when working with commands, with the possibility of erun multiple commands at once in a simple and easy way, saving time. To install it, you can find it in most repositories of major distributions, so you will only have to use the package manager you use followed by the name parallel to install it. Once installed, its operation is not complicated either, as we are going to show you.

For example, if you want to change the format of several .jpg files, you will probably start by using a command for each of the existing files, but if there are too many it becomes complicated. In case of being somewhat more experienced and in case of having enough files to work with, going one by one is not practical, so you will surely use a script to help you with the job to automate the job.

Instead, with GNU Parallel it will be in a similar to the xargs command if you've ever used it. For example, to change the format from .jpg to .png we could do the following:

find /home -name "*.jpg" | parallel -I% --max-args 1 convert % %.png

With that we get the find command to search all the .jpg files in the / home directory with any name and pass all the results to parallel through the pipe, which will then transmit one by one to the convert command to convert them to png. That is, it will perform convert name1.jpg name1.png, convert name2.jpg name2.png, and so on ...


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.