How to use tee In Linux
The tee command reads standard input and copies it to both standard outputs and to one or more files.
Syntax:
tee /home/kalilinux/dir1/xyz.txt /home/kalilinux/dir2/xyz.txt /home/kalilinux/dir3/xyz.txt< xyz.txt
If you just want to read standard input and copy it into one or more files without showing the standard output then you can use >/dev/null at the end of the above command. For example:
tee /home/kalilinux/dir1/xyz.txt /home/kalilinux/dir2/xyz.txt /home/kalilinux/dir3/xyz.txt< xyz.txt >/dev/null
Output:
Note: It is a must to give any file name at the end of the destination after giving the directory’s location. It can be different from the name of the file that we copy into the directories or can be the same as the file name.
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: