0

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:

7msf_stem_0_mcannotate.pdb
7msf_loop_3_mcannotate.pdb
6tna_strand_10_mcannotate.pdb
7msf_strand_4_mcannotate.pdb

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
3

try

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

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.