Short: Move A File To Multiple Directories

Today’s article should be a fairly short article, where I take the chance to show you how to move a file to multiple directories – at the same time. It’s a pretty simple process, albeit a bit weird. If you want to move files to multiple directories, this is the article for you!

I’ve done a lot of articles about file management. This is another one. We usually manage files in the terminal here on Linux Tips. We’ll be doing that again this time around. We’ll be managing files in the terminal!

The tool we’ll be using is the tee command. I covered that recently.

The task we’ll be doing is showing you how to move a file to multiple directories – at the same time and in the Linux terminal. It’s a pretty handy skill to have, though there’s some tee weirdness along the way.

Move A File To Multiple Directories:

You’ll need an open terminal for this, as the intro suggested. You can find a terminal application in your GUI file manager. You can often open your default terminal by pressing CTRL + ALT + T on your keyboard.

With your terminal open, let’s just run through some exercises to ensure we’re all on the same page and ready to move a file. 

First, let’s make a directory:

Next, let’s move to that directory:

Next, let’s make that file that we’ll copy to multiple directories:

I suppose we’ll need a few folders next, so let’s create them:

Now, let’s move the file foo to multiple directories:

The syntax is:

We throw the & in so that the tee command doesn’t hang, awaiting further input. You’ll get an extra message or two, but that’s fine and can be ignored.

Now, we can verify them:

The following command will show you that the file exists:

That should show the file, like so:

Now, you can check the other folders. 

And, of course:

Each of those should show you that the foo file exists in each directory.

Now, we can clean up after ourselves with this command:

Tada! Now there shouldn’t be any remains left behind and we’ve covered how to move a file to multiple directories at the same time and in the Linux terminal.

Pretty easy and pretty short!

Closure:

You never know when you’ll want to move a file to multiple directories but now you know how to do so. It isn’t a very difficult exercise, warranting only a short article. This seemed like good fodder for a short article and a handy tip to share with my readers.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.