Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have a directory that contains the following:


I have been using mv dir* /someotherpath/, then move the *.txt files back. If there a way to move only the directories?

share|improve this question
up vote 8 down vote accepted

If your directory structure is only 1 level deep mv dir*/ destination will accomplish this task.

share|improve this answer
Thanks! The key was the forward slash. – John_Sheares Oct 12 '12 at 23:25

You can also use find to accomplish this task

find . -maxdepth 1 -type d -name "dir*" -exec mv '{}' destination/ \;

Change maxdepth parameter or remove it if you directory structure has more levels

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .