Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a folder with many sub-folders containing small tif files (less than 160kb) which have been merged together in bigger pdf files, together with some big multi-page tif files.

I want to delete all small tif files without deleting the bigger files (tif or pdf) and retaining the directory structure. How do I go about it on Linux using the command-line?

share|improve this question
up vote 47 down vote accepted
find . -name "*.tif" -size -160k -delete

To verify that the correct files are found run the command without -delete first.

Note the - at -160k. Just 160k means exactly 160 kilobytes. -160k means smaller than 160 kilobytes. +160k means larger than 160 kilobytes.

share|improve this answer
    
The ubuntu man page seems to mention this. Just below the "TESTS" section: Numeric arguments can be specified as +n for greater than n, -n for less than n, n for exactly n. – jdg Sep 11 '14 at 23:55
    
thanks. it did not occur to me that the information might be somewhere else in the manpage. – lesmana Sep 12 '14 at 8:55
    
It is nice this command also works recursively. My use case would be to delete .txt files under 12kB. – Sun Sep 23 '14 at 4:21
    
no need for sudo? – Jean-François Gagnon Oct 6 '15 at 15:35
2  
For sizes in bytes specify 50c, not 50b or 50! – Evengard Jan 29 at 13:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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