Skip to content

Instantly share code, notes, and snippets.

@dfrencham
Created September 23, 2014 22:48
Show Gist options
  • Save dfrencham/605cdcc653f07bdd5a79 to your computer and use it in GitHub Desktop.
Save dfrencham/605cdcc653f07bdd5a79 to your computer and use it in GitHub Desktop.
Find duplicate css classes in a file
# 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