Is there a DOS command to count the number of lines in a text file ?
Results 1 to 5 of 5

Thread: Is there a DOS command to count the number of lines in a text file ?

  1. #1
    Nix's Avatar
    Nix is offline Aka: Nix*, NNiixx, Nix23
    Join Date
    May 2001
    Location
    Sydney, Australia
    Posts
    8,255

    Is there a DOS command to count the number of lines in a text file ?

    Someone told be there's one in Unix and they suggested there was probably one in DOS.

    So, is there or not ?

  2. #2
    Join Date
    Jan 2003
    Location
    Australia
    Posts
    1,743
    I don't remember any version of DOS having native line or word count, it was one of the missing features people wrote utilities to provide, like here:

    http://members.optushome.com.au/quentinc/ti.html

  3. #3
    Join Date
    Feb 2000
    Location
    26.03°N 80.14°W
    Posts
    9,410
    For example:
    • find/c/v "~`!@#$%^&*()_+" c:\foobar.txt
    In other words, we've told FIND to count ("/c") the number of lines that do not contain ("/v") a string of text ("~`!@#$%^&*()_+") that is unlikely to exist in the file ("c:\foobar.txt"). FIND will return a result similar to:
    • ---------- c:\foobar.txt: 143
    (The "143" is the number of lines found).
    Vernon Frazee, Microsoft MVP (Windows - Shell/User)

    Defenses Up!
    Tip: When prompted for a password, give an incorrect one first. A phishing site will accept it; a legitimate one won't.


    Inside Spyware: A Guide to Finding, Removing and Preventing Online Pests


    If you don't keep up with security fixes, your computer|network won't be yours for long.

  4. #4
    Nix's Avatar
    Nix is offline Aka: Nix*, NNiixx, Nix23
    Join Date
    May 2001
    Location
    Sydney, Australia
    Posts
    8,255
    Thanks to you both.

    Vernon I think I like your option.

    Cheers.

  5. #5
    Join Date
    Feb 2000
    Location
    26.03°N 80.14°W
    Posts
    9,410
    You're Welcome.

    BTW, if you'd rather not see the:
    • ---------- c:\foobar.txt:
    in the DOS (FIND's) response, you could use something like:
    • type c:\foobar.txt|find/c/v "~`!@#$%^&*()_+"
    instead. All you'll get then is simply the number of lines.
    Vernon Frazee, Microsoft MVP (Windows - Shell/User)

    Defenses Up!
    Tip: When prompted for a password, give an incorrect one first. A phishing site will accept it; a legitimate one won't.


    Inside Spyware: A Guide to Finding, Removing and Preventing Online Pests


    If you don't keep up with security fixes, your computer|network won't be yours for long.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •