How to use GNU parallel In Linux

First, you need to install this on your pc/laptop because it may not be pre-installed in your Linux operating systems. You can install it by using the command:

sudo apt install parallel

then after we use:

parallel cp -v xyz.txt ::: /home/kalilinux/dir1 /home/kalilinux/dir2 dir3

GNU Parallel is a shell utility for executing jobs in parallel which makes running the command against sets of data at the same time easier. Here we are using:

  • parallel: This keyword uses the GNU Parallel.
  • cp: to perform the copy task.
  • -v: to display informative messages as the copy is performed.

Output:

Using GNU parallel

How to Copy a File to Multiple Directories in Linux

In this article, we will discuss how to copy a file to multiple directories in Linux. xargs, find, tee, shell loop, and parallel are the commands that can help you to copy a File to Multiple Directories.

Suppose we have a file with the name “xyz.txt” and we want to copy it into 3 directories with the name dir1, dir2, and dir3 then we use the following methods:

Similar Reads

Using xargs

xargs command on Unix/Linux operating system converts input from standard input into an argument list for a specified command....

Using find

Here, the command find initiates a search and allows actions to be performed based on the search results....

Using Shell loop

Here, we are using bash for loop to copy the xyz.txt file in the /home/kalilinux/dir2 /home/kalilinux/dir3 directories and also a folder dir1, directly where:...

Using tee

The tee command reads standard input and copies it to both standard outputs and to one or more files....

Using GNU parallel

First, you need to install this on your pc/laptop because it may not be pre-installed in your Linux operating systems. You can install it by using the command:...

Conclusion

In this article we have discussed how to copy a file to multiple directories in Linux and how it can be achieved using various methods, such as utilizing the `cp` command with brace expansion, leveraging `find` and `xargs`. Each method provided flexibility and efficiency in different scenarios. Overall, we can say that after understanding these methods and adapting them to our specific requirements, we can save time and effort when dealing with the directories in Linux....