Read lines with awk regardless of line ending style

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

+2


source to share


3 answers


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



+2


source


You can write a script to count the number of lines and get the perfect result. The script for this is also available here Count Number of lines in UNIX that have data



+1


source


What about

grep -c '^.*$' filename

      

0


source







All Articles