Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd please sign up again. Thanks!

How to count how many lines a file have?

Discussion in 'General Linux' started by carbon333, Feb 16, 2012.

  1. carbon333

    carbon333 Guest

    You can do this by typing:

    wc -l file.txt

    Also if you want know the number of words or characters, type:

    wc file.txt
  2. ----- text file. Click on Edit>Go To. Give a huge number than expected number of lines. say if you expect to have 2000 lines, give 5000 or just give 200000. It gives an eror "The Line number is beyond the total number of lines" and shows up the the immediately available line. If you have 2379 lines it gives 2380. So whatever it shows up minus 1 is the actual number of lines in the text file.
  3. chemic

    chemic Guest

    In vim you can see how many lines in line when you go to end file. Number lines and character in lines is display in down.
  4. dale

    dale Guest

    wc is cleaner, but I will also mention the following use of cat and tail (haha) because I use it a lot:
    cat -n [I]file_name[/I]|tail -5
    This will list out the last five lines of the file, with the lines numbered.

Share This Page