Demon Demon - 1 year ago 111
Bash Question

UNIX command for record count at one go

Please help me with the command to get the record count of files in a directory. I know wc -l filename will give me the count , but is there a single command to display record count for all files in the directory at one go?

Answer Source

Of course there is:

wc -l /dirname/*

If you have directories inside /dirname/ you'll see some errors about trying to apply wc to a directory. In that case you can use:

find /dirname/ -maxdepth 1 -type f | xargs wc -l

Or if you want to go full recursive:

find /dirname/ -type f | xargs wc -l
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download