Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I need a one line perl command to find & list all 0 byte files in a directory. I need to run this command from windows cmd.

Thanks.
  • Comment on How to find & list 0 byte files in a directory

Replies are listed 'Best First'.
Re: How to find & list 0 byte files in a directory
by BrowserUk (Patriarch) on Apr 10, 2012 at 17:43 UTC

    perl -E"-s or say for grep -f,glob '*'"

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      A little bit smaller:
      perl -E"-z-f&&say,while<*>"

        Two less:

        perl -E"-z-f&&say for<*>"

        And you can remove the trailing ".

Re: How to find & list 0 byte files in a directory
by MidLifeXis (Monsignor) on Apr 10, 2012 at 17:47 UTC
Re: How to find & list 0 byte files in a directory
by ikegami (Patriarch) on Apr 11, 2012 at 03:05 UTC

    Non-recursive:

    c:\progs\cygwin\bin\find . -maxdepth 1 -type f -size 0c
    :: In a batch file. @echo off for %%q in (*) do if (%%~zq)==(0) echo %%q
    perl -E"say for grep -z -f, glob '*'"
    perl -MFile::Find::Rule -E"say for File::Find::Rule->maxdepth(1)->file +->empty->in('.');"

    Recursive:

    c:\progs\cygwin\bin\find . -type f -size 0c
    :: In a batch file. @echo off for /r %%q in (.) do if (%%~zq)==(0) echo %%q
    perl -MFile::Find::Rule -E"say for File::Find::Rule->file->empty->in(' +.');"