Server Fault is a question and answer site for system and network administrators. 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

I'd like to move all sub-folders starting with a given suffix (Blah_ in the example) into an other directory using a linux bash script. Here's what the script looks like:

mv -v -f "$srcDir$prefix*" -t $archiveDir

Though there are a lot of directories starting with 'Blah_', inside /home/me, this leads to the following error message:

mv: cannot stat `/home/me/Blah_*': No such file or directory

Now I'm curious whats wrong here. How must the above script be changed in order to move all subfolders starting with 'Blah' into the archive folder?

share|improve this question
Remove the quotes – Zoredache Aug 8 '12 at 21:08
up vote 3 down vote accepted
mv -v -f ${srcDir}${prefix}* -t $archiveDir

in this case if you quote, * will be interpreted literally

share|improve this answer
Perfect! Thank you very much! – Tolaksa Aug 8 '12 at 21:33

How about:

find   /home/me   -type   d   -name   "Blah_*"   -exec   mv   -i  {}  /Archive \;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.