Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count number of rows in a text file using linux [duplicate]

Tags:

linux

row

I want to know how to get the number of rows in a text file using Linux. I have tried "wc " and "wc -l ", but both display only the number of lines (columns) not the rows. Any idea?

like image 917
Adam Majdi Avatar asked Dec 13 '25 21:12

Adam Majdi


1 Answers

wc -l < <filename> displays lines for me

example file with numbers 1 - 7

outputs:

scottsmudger@ns207588:~ $wc -l < test
7

From the man page:

-l, --lines
    print the newline counts
like image 154
ScottSmudger Avatar answered Dec 16 '25 12:12

ScottSmudger