I want to delete files which size is between certain values. For example I have the following list of files:
-rw-r--r-- 1 smsc sys 558 Apr 30 13:07 stats.sfe.1.20120430130513.xml.Z
-rw-r--r-- 1 smsc sys 388 Apr 30 15:32 stats.sfe.1.20120430153013.xml.Z
-rw-r--r-- 1 smsc sys 386 Apr 30 15:36 stats.sfe.1.20120430153513.xml.Z
-rw-r--r-- 1 smsc sys 389 Apr 30 15:42 stats.sfe.1.20120430154013.xml.Z
-rw-r--r-- 1 smsc sys 390 Apr 30 16:02 stats.sfe.1.20120430160013.xml.Z
-rw-r--r-- 1 smsc sys 385 Apr 30 16:12 stats.sfe.1.20120430161013.xml.Z
From the above list, I want to delete only the files which size varies between 386b and 390b. I know that I can use the following command to delete files which size exceed certain <size>
:
find . -size +<size>-delete
But how can I add one more boundary for files which size is less than a given value?
Best Answer
A range is simply an upper bound AND a lower bound. From the
find
spec:So all you need to do is specify both size bounds before the
-delete
action.