in reply to number of files in current directory - one liner

perl -le 'opendir X, shift; $x = () = readdir X; print $x' somedir

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: •Re: number of files in directory - one liner
by particle (Vicar) on Mar 27, 2002 at 16:33 UTC
    nope. this lists directories and symlinks too. i'm trying to list just files. jmcnamara has an uglier solution, but it works ;)

    ~Particle ;̃

        I feel like golfing ;)

        # 123456789_123456789_123 perl -le'print~~grep-f,<@ARGV/*>' dir # Assuming a single dir, of course. And assuming a *nix-like environme +nt with unbroken libraries.
        I like glob() and chicken.

        U28geW91IGNhbiBhbGwgcm90MTMgY
        W5kIHBhY2soKS4gQnV0IGRvIHlvdS
        ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
        geW91IHNlZSBpdD8gIC0tIEp1ZXJk