linux - Delete files with a similar names, matching a range -


I have many similar name files. The difference in their name is just an increased number. For example, the Linux kernel:

  rc linux-image-3.2.0-29-generic 3.2.0-29.46 64 bit x86 SMP RC on Linux 3.2 for Linux kernel image Linux- Image- 3.2.0-31-64 bit x86 SMP RC Linux kernel image for generic 3.2.0-31.50 version 3.2.0 for linux-image-3.2.0-32-generic 3.2.0-32.51 version 3.2.0 Linux kernel image for version 3.2.0 on Linux kernel image 64 bit x86 SMP RC linux-image-3.2.0-33-generic 3.2.0-33.52 64 bit x86 SMP RC Linux-Image-3.2.0-34- Generic 3.2.0-64.53 lyn Linux kernel image for version 3.2.0 on Linux image-3.2.0-35-generic 3.2.0-35.55 64 bit x86 SMP on Kernel image 64 bit x86 SMP RC on version 3.2.0 ... More than  

I would like to delete most of them. Say, from 29 to 35 There are too many to use the sudo apt-get purge linux-image-x.x.x.x-generic manually. What script should I write to?

You can delete files based on your name pattern. For example, do:

  rm linux-image-3.2.0- {29..35} -genable  

Before and, make sure To implement that you are removing the right things, execute the command with ls to see which files will be affected.


Comments