Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the line-count of all the files in a directory

Tags:

linux

bash

I'm asked to get the line count of all the files in some directory for which the path will be provided as a terminal argument.

My solution so far is:

wc -l "$1/"*

But doing this also gives me some unnecessary output like this:

wc: '/home/user/Desktop/Dir': Is a directory

So how can I print only the results for actual files not directories? And then how could I only display the ones that have been edited at most 10 minutes ago?


1 Answers

Thy this:

find ./pathToDirectory -type f -exec wc -l {} +
like image 135
cn007b Avatar answered Sep 09 '25 22:09

cn007b