Created
September 23, 2014 22:48
-
-
Save dfrencham/605cdcc653f07bdd5a79 to your computer and use it in GitHub Desktop.
Find duplicate css classes in a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# One liner! | |
# Finds all duplicate CSS classes in a CSS file, and ignores hex colour codes (the #DDDDDD pattern would be a false positve) | |
Get-Content .\filename.css | ForEach-Object { $_.Split(" ,.", [System.StringSplitOptions]::RemoveEmptyEntries) } | ForEach-Object { $_.Trim() } | where { ($_[0] -eq "#" -or $_[0] -eq "." ) -and (!$_.EndsWith(";")) } | where {$_ -notmatch '#[0-9a-fA-F]{2,}$'} | sort-object | group-object | where-object { $_.Count -gt 1 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment