in reply to how to get total numbers of files in a directory?

This code should do what you want:

perl -le 'print scalar @{[</home/a/*.txt>]}'

Welcome to the forum!

Replies are listed 'Best First'.
Re: Re: how to get total numbers of files in a directory?
by flounder99 (Friar) on Dec 09, 2003 at 15:53 UTC
    Watch out for dirctories ending in .txt
    $ touch temp.txt $ mkdir dir.txt $ perl -le 'print scalar @{[<./*.txt>]}' 2
    Try this:
    $ perl -le 'print scalar @{[grep {-f} <./*.txt>]}' 1

    --

    flounder