Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: how to get total numbers of files in a directory?

by delirium (Chaplain)
on Dec 09, 2003 at 13:43 UTC ( [id://313409]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://313409]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2026-01-13 03:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (118 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.