in reply to Re: finding top 10 largest files
in thread finding top 10 largest files

Purists may want to use File::Find instead of find.

Purists or Win32 users like the OP for example....

cheers

tachyon

Replies are listed 'Best First'.
Re: finding top 10 largest files
by Abigail-II (Bishop) on Feb 03, 2004 at 00:14 UTC
    Oh, come on. You must know by now that the standard Unix tools have been ported to Windows, multiple times?

    There's no reason to feel left out if you're on a Windows platform, and someone uses 'find'.

    Abigail

      I suppose you could use this too (if you had enough ports)....
      find / -type f -print|xargs ls -l|sort -rnk5|head -10

      cheers

      tachyon

        Yes, you could. I realized that, but didn't present it, because it's neither efficient memory wise (as you are processing all the file names at the same time), nor is it run-time efficient, as you are sorting all the file names, and that's Omega (N log N). The solution where you keep a sorted buffer takes linear time.

        If you want to factor in the amount of files (let's say k) to be reported, the solution you present takes O (N log N + k), while my solution takes O (k N). If you replace the array with a heap, you can reduce that to O (k + N log k). The used memory in your solution is O (N), and O (k) in my solution.

        All mentioned upperbounds are tight.

        Abigail

Re: Unix Utilities for Win32 (OT)
by Brutha (Friar) on Feb 03, 2004 at 15:22 UTC
    Please excuse me, for being 95% off topic, but maybe a search should reveal the following link. For me Perl is mainly commandline work and I love less, which, find, etc and their combinations.
    Thank You.

    With the exception of which, which has a better Perl equivalent called pwhich, you should try http://unxutils.sourceforge.net/ as standalone alternative for cygwin.
    Quote from description:

    Here are some ports of common GNU utilities to native Win32. In this context, native means the executables do only depend on the Microsoft C-runtime (msvcrt.dll) and not an emulation layer like that provided by Cygwin tools.

    But nevertheless you run into problems with find and echo as they have DOS equivalents commands with the same name, but limited functionality. If you have Novell, you will hit e.g. ls, depending on your path.

    And it came to pass that in time the Great God Om spake unto Brutha, the Chosen One: "Psst!"
    (Terry Pratchett, Small Gods)

      You might have luck with this pipeline
      du -a | sort -nr | head -10
      which would give the top 10 files recursively found below the directory this command is issued from. The cross-platform GNU utilities would list the top-ten files.