How to count how many lines a file have?

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

  1. carbon333

    carbon333 New Member

    Messages:
    87
    Likes Received:
    6
    Trophy Points:
    0
    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. Stefano Messicano

    Stefano Messicano New Member

    Messages:
    88
    Likes Received:
    3
    Trophy Points:
    0
    ----- 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 New Member

    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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 Member

    Messages:
    115
    Likes Received:
    7
    Trophy Points:
    18
    wc is cleaner, but I will also mention the following use of cat and tail (haha) because I use it a lot:
    Code:
    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