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?
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 {} +
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With