Windows XP
My batch file runs a command that has several lines of output. How can I count (and store in a variable) the lines of output without ever writing to the disk?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s sample script that will count the lines in the output of the
dircommand.You can substitute
dirwith your command and you can use quotes and specify parameters. You will have to escape some other characters though –^,|<>and&.If you need to not only count the lines, but also parse each line, you might have to change the token delimiter from
_(as I used in the example) to something else that will not result in the line split in multiple tokens.