9

Working with huge CSV files for data analytics, we commonly need to know the row count of all csv files located in a particular folder.

But how to do it with just only one command in Linux?

Cesar Augusto Nogueira
  • 1,911
  • 1
  • 14
  • 14

2 Answers2

10

If you want to check the total line of all the .csv files in a directory, you can use find and wc:

 find . -type f -name '*.csv' -exec wc -l {} +
Cesar Augusto Nogueira
  • 1,911
  • 1
  • 14
  • 14
5

To get lines count for every file recursively you can use Cesar's answer:

$ LANG=C find /tmp/test -type f -name '*.csv' -exec wc -l '{}' +
 49 /tmp/test/sub/3.csv
 22 /tmp/test/1.csv
419 /tmp/test/2.csv
490 total

To get total lines count for all files recursive:

$ LANG=C find /tmp/test -type f -name '*.csv' -exec cat '{}' + | wc -l
490
Tns
  • 390
  • 1
  • 7