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 ?

Community
  • 1
  • 1
Иво Недев
  • 1,570
  • 1
  • 20
  • 33
  • 1
    Seems like it'd be pretty easy for you to test & find out for yourself. – alroc Feb 09 '16 at 14:18
  • @alroc It never occurred to me but now reading it - yes, you are quite correct, thanks! – Иво Недев Feb 09 '16 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` . – beatcracker Feb 09 '16 at 15:01

1 Answers1

1

No

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

Community
  • 1
  • 1
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206