Adam Majdi Adam Majdi - 4 years ago 114
Linux Question

Count number of rows in a text file using linux

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?

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download