tags:

views:

161

answers:

2

What's the best way to count the number of line in a file with awk, regardless of line-ending style (DOS/Windows, UNIX, etc.)?

A: 

How about

grep -c '^.*$' filename
Peter
Nope -- same thing. It reports one line for files using the CR-only line ending style.
Tyson
ok, sorry to waste your time.
Peter
Thanks for your time, though!
Tyson
A: 

do a dos2unix or unix2dos on the file first, before using awk.

ghostdog74