wc -l <file>
will print out the number of lines in <file>.If you have a collection of files (.csv in the example below), and want to know how many rows are in each file, the command:
for f in *.csv; do wc -l $f; done
will print out a list of all the files ending in .csv, along with the number of lines in them.To print the number of lines, without the filename, the cut command can be used, with the following parameters:
cut -d' ' -f1
Combining them, we can use:
for f in *.csv; do wc -l $f |cut -d' ' -f1; done
to print out just the number of lines in each file ending in .csv in the directory.