Deleting all empty files with a single command?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

Octavian Rasnita 03.06.02:

>I want to delete all empty files from a directory with a single command.
>What switch should I use to "select" all the empty files?

  In command line you can write:
find . -maxdepth 1 -type f -size 0 -exec rm {} \;

  ...well: find is a command to find files for certain criteria. First
dot means start from current directory, -maxdepth 1 means not recursing
into subdirectories, -type f means only ordinary files, -size 0 is quite
obvious and -exec will launch rm to erase file if all previous
conditions are met. {} in exec is replaced by file name and \; means end
of -exec command.

  To see more options see find man page:-)

-- 
Mr. Ari Moisio, Niittykatu 5, 41160 Tikkakoski, +358-40-5055239
ari.moisio at iki.fi http://www.iki.fi/arimo PGP-keyID: 0x3FAF0F05





[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]
  Powered by Linux