How to count no of lines in text file and store the value into a variable using batch script?

前端 未结 16 1249
青春惊慌失措
青春惊慌失措 2020-11-27 14:28

I want to count the no of lines in a text file and then the value has to be stored into a environment variable. The command to count the no of lines is

findstr /R         


        
16条回答
  •  甜味超标
    2020-11-27 15:01

    There is a much simpler way than all of these other methods.

    find /v /c "" filename.ext
    

    Holdover from the legacy MS-DOS days, apparently. More info here: https://devblogs.microsoft.com/oldnewthing/20110825-00/?p=9803

    Example use:

    adb shell pm list packages | find /v /c ""
    

    If your android device is connected to your PC and you have the android SDK on your path, this prints out the number of apps installed on your device.

提交回复
热议问题