Remove all jpegs les than 1k from a folder

Posted on 2006-05-20
Last Modified: 2013-12-16
Hi i am new to linux so sorry for the no braner question but how do i remove all jpg files less than 1k from a spesific folder?
its to go in a cron script
thanks for you help
Question by:kingpin200004
    LVL 43

    Accepted Solution

    find /dir -name '*.jpg' -size -10k -exec rm -f {} \; # will remove all *.jpg within /dir and subdirs that are smaller than 10KB
    want some moification? Ask or read 'man find'

    for testing purposes You may issue
    find /dir -name '*.jpg' -size -10k -print
    LVL 43

    Expert Comment

    Also if You expect large number of files in one run, You can speed it up with
    find /dir -name '*.jpg' -size -1k -printf "'%p'\n" | xargs rm -f

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
    SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now