Skip to content

Instantly share code, notes, and snippets.

@harmoniemand
Last active March 12, 2018 14:33
Show Gist options
  • Save harmoniemand/bb53396b45ad7ebc070d to your computer and use it in GitHub Desktop.
Save harmoniemand/bb53396b45ad7ebc070d to your computer and use it in GitHub Desktop.
Powershell count lines of code
# Count Lines
(dir -include *.cs -recurse | select-string "^(\s*)//" -notMatch | select-string "^(\s*)$" -notMatch).Count
# Search String
$search = "focusSearchInputfield";
Get-ChildItem -Recurse | Where { ! $_.PSIsContainer } | Select-String $search | select LineNumber, Path, Filename |Format-List
(dir -include * -recurse | select-string "_recurse")
# Count all Files
(dir -include * -recurse).Count
# Count all files exclude pattern
(Get-ChildItem -Recurse | Where {$_.FullName -notlike "*\node_modules\*"} | select-string "^(\s*)//" -notMatch | select-string "^(\s*)$" -notMatch).Count
# get all filenames as strings in a text-file
get-childitem -recurse | where { ! $_.PSIsContainer } | % {
$_.FullName | Out-File test.txt -Append
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment