Delete All *.exe Files Depending on FileSize

Posted on 2011-04-20
Last Modified: 2012-08-13
Hi, what command line to delete all *.exe files depending on filesize, eg. i want to delete all *.exe with filesize = 1000 bytes?
Question by:wuyinzhi
    LVL 3

    Expert Comment

    Log on via root :

    this command will generate the list

    find / -name '*.exe' -size +1K

    After that, you can delete file whatever you want
    LVL 3

    Author Comment

    thanks, but since i'm new in linux, can i define exact bytes instead of +1K?
    also, what should i do after i get the list? should i rm manually per-line?
    LVL 3

    Accepted Solution

    yes you can define exact bytes:

    For auto delete :

    use :

    find / -name '*.exe' -size +1K -exec rm -rf { }\;

    LVL 16

    Expert Comment

    Yes, you can define the size exact bytes, eg. 1000bytes will be 1000nc. So the command is:
    # find / -type f -name *.exe -size 1000nc -exec rm -f {} \;
    LVL 3

    Author Comment

    many thanks ganjos

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    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…
    It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

    754 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

    18 Experts available now in Live!

    Get 1:1 Help Now