find . -size 1400c -exec rm {} \;

remove files of a specific size

Removes all files in the current folder that are 1400 bytes in size.

0
By: gef
2011-08-18 15:19:24

These Might Interest You

  • Very useful for finding all files over a specified size, such as out of control log files chewing up all available disk space. Fedora Core x specific version. Show Sample Output


    1
    find / -type f -size +25M -exec ls -lh {} \; | awk '{ print $5 " " $6$7 ": " $9 }'
    darkon1365 · 2009-02-16 12:27:48 2
  • Remove all zero size files from current directory. Its a not recursive option like: find . -size 0c -exec rm {} \;


    -8
    ls -s|grep -E "^ *0"|sed "s/^ *0 //g"|xargs -i rm "{}"
    glaudiston · 2012-04-18 14:50:46 3
  • This will create a 10 MB file named testfile.txt. Change the count parameter to change the size of the file. As one commenter pointed out, yes /dev/random can be used, but the content doesn't matter if you just need a file of a specific size for testing purposes, which is why I used /dev/zero. The file size is what matters, not the content. It's 10 MB either way. "Random" just referred to "any file - content not specific" Show Sample Output


    1
    dd if=/dev/zero of=testfile.txt bs=1M count=10
    mstoecker · 2009-06-17 17:06:16 7

  • 10
    find . -maxdepth 1 -size 0c -delete
    joedhon · 2012-04-18 15:01:48 3
  • Then you can remove the specific entry: iptables -D INPUT 10 Just make sure these are set: IPTABLES_SAVE_ON_STOP="yes" IPTABLES_SAVE_ON_RESTART="yes" Else your changes won't stick when you restart iptables. Show Sample Output


    2
    iptables -L INPUT --line-numbers
    jmorganwalker · 2013-12-19 16:14:25 1
  • If, for example, you want to remove all kernels and headers but the last three versions, you can't use one of that magic all-in-one "remove old stuff" commands. With this simple but elegant command you can remove a range of versions, or a list of versions with e.g. {14,16,20}. Show Sample Output


    1
    apt purge linux*{14..18}*
    ppq · 2016-04-20 07:44:55 0

What Others Think

find . -size 1400c -delete
h3xx · 351 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: