• AndrewN (unregistered) in reply to cihv

    awk 'END{print NR}' <filename>


  • John (unregistered) in reply to cihv

    No need to count lines, awk already does it:

    awk 'END {print NR}' <filename>

  • eVil (unregistered)

    Astonishingly, amongst all this to-ing and fro-ing regarding C-Octothorpe, and relative idiocy with respect to obviousness of the other guys intended irony...

    No-one has seemed to notice that a one-man circle jerk doesn't really work.

    Why Octothorpe didn't notice that himself and point out that it is quite obviously superior to be strumming solo, god only knows.

    Also, platform fanboys really ought to have stopped being those by now.

  • bitti (unregistered)

    Unbelievable that still nobody mentioned the simplest solution

    sed -n $= /var/run/netstat_r.lst

  • reductio ad ridiculum (unregistered) in reply to swahl
    I believe this counts non-blank lines:

    cat file | grep -v "^[ \t]*$" | wc -l

    I know, save the cats! But I like using cat in front of a long pipe because it's clearer to me.

    I never got why people don't just use this approach to avoid the extra cat:

    <file grep -v "^[ \t]*$" | wc -l

    Good one!

    Pretty much looks like line noise.

  • smit (unregistered) in reply to Camel

    perl -lne 'END{print $.}' /var/run/netstat_r.lst

Leave a comment on “How Not to Count Lines”

Log In or post as a guest

Replying to comment #:

« Return to Article