Reputation: 285
I tried using wc -l
, but it says Argument list too long
. Is there an alternative? The total number of files in the directory is 100k+ and there are too many lines per file as well (200k+ in each).
Upvotes: 0
Views: 92
Reputation: 362037
If you want a separate count for each file, do:
find /dir -exec wc -l {} +
-exec +
is smart and will call wc
multiple times with partial file lists so as not to exceed the OS's command line length limit.
If you want one combined count for all files, do:
find /dir -exec cat {} + | wc -l
By concatenating all of the files together only one wc
invocation is needed.
Upvotes: 5