Recursive rm with condition in Linux

Posted by zengr on Super User See other posts from Super User or by zengr
Published on 2011-03-13T05:54:08Z Indexed on 2011/11/20 10:00 UTC
Read the original article Hit count: 179

Filed under:
|
|

I have the following folder structure:

parent
 - folder1
   - main1.x
   - main1.y
   - main1.z
   - main1-626262.x
   - main1-626263.x
   - main1-626264.x
   - main1-626265.x
   - main1-626266.x
   - main1-626267.x
 - folder2
   - main2.x
   - main2.y
   - main2.z
   - main2-726262.x
   - main2-726263.x
   - main2-726264.x
   - main2-726265.x
   - main2-726266.x
   - main2-726267.x

Now, I want to remove: main-*********.x

So, my required folder structure:

parent
 - folder1
   - main1.x
   - main1.y
   - main1.z
 - folder2
   - main2.x
   - main2.y
   - main2.z

So, how can I achieve this?

© Super User or respective owner

Related posts about linux

Related posts about command-line