I have a folder containing lots of files like 3 lac plus files. I have to separate them according to their names in three different folders. e.g. a few names are:


I have to keep all the files containing "stem" in their name in one folder called stem, those containing "loop" in their names in another folder called loops, while those containing "strand" in their name called strands.

Is there a shell script to do that?

  • 1
    Well, there will be a shell script if you program it. – mdpc Mar 23 '15 at 7:10
  • well that was quite helpful lol.. actually I am quite new to linux and I need to solve this problem. I need some help thats the sole purpose of posting this question – Lily Sharpton Mar 23 '15 at 8:37


 mkdir ../loops ../stems ../strands
 for x in loop stem strand
    mv *${x}* ../${x}s

please note that dirs will be on a parent folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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