0

I'm trying to count the lines of code in my project. It's on a remote server, so I can't exactly install software, I can but it's not that easy and it's not worth the trouble. Trying to count my lines of code I found this piece of code that works and spits out a number.

My questions is, does

(dir -r -include   *.cs,*.html | select-string . ).count

count empty lines when executed in the root project folder, or just those with anything on them ?

3
  • 1
    Seems like it'd be pretty easy for you to test & find out for yourself. Commented Feb 9, 2016 at 14:18
  • @alroc It never occurred to me but now reading it - yes, you are quite correct, thanks! Commented Feb 9, 2016 at 14:36
  • 1
    You don't even need regex to do this: (Get-ChildItem -Recurse -Include '*.cs', '*.html' | Get-Content | Where-Object {$_.Trim()}).Count or (gci -r -i *.cs, *.html | gc | ? {$_.Trim()}).Count . Commented Feb 9, 2016 at 15:01

1 Answer 1

1

No

Your regex pattern: ., will match any 1 character, but a truly empty line has exactly 0 characters, so the answer is no.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.