Skip to content

Instantly share code, notes, and snippets.

@phiggins
Created April 18, 2016 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phiggins/d6e91605ba744090c2a54466ea3ad29a to your computer and use it in GitHub Desktop.
Save phiggins/d6e91605ba744090c2a54466ea3ad29a to your computer and use it in GitHub Desktop.
# Find all strings in a CSS file or files that start with a '.' and
# stop on some common CSS delimiters.
# This is only looking at _map.scss, but you could look at any other file or even
# app/assets/stylesheets if you wanted to see everything.
grep -hro "\.[^ .,():]\+" app/assets/stylesheets/partials/mobile/_map.scss |
# The sort | uniq part makes it so we don't look for duplicates.
sort |
uniq |
# Loop over the things we just found.
while read i ; do
# Look in other files for references to the strings we just found. The important
# part here is that I'm limiting my search to app/views/ and
# app/assets/javascripts, where we're probably likely to see the most references to
# CSS classes.
echo $(grep -r $i app/views app/assets/javascripts/ | wc -l) $i ;
done |
# Then sort the results so we get all the least-used selectors at the end.
sort -rn
# Here's the one-liner version
grep -hro "\.[^ .,():]\+" app/assets/stylesheets/partials/mobile/_map.scss | sort | uniq | while read i ; do echo $(grep -r $i app/views app/assets/javascripts/ | wc -l) $i ; done | sort -rn
# Here's what the ouput looks like. The number in the left hand column is the
# number of occurences it found, so the ones with 0 are the potential ones to
# delete.
pete@balloon:~/work/estately$ grep -hro "\.[^ .,():]\+" app/assets/stylesheets/partials/mobile/_map.scss | sort | uniq | while read i ; do echo $(grep -r $i app/views app/assets/javascripts/ | wc -l) $i ; done | sort -rn
1028 .3
555 .8
537 .save
515 .current
266 .price
213 .filter
193 .address
181 .btn
179 .disabled
127 .disclaimer
84 .office
75 .trash
68 .details
53 .pagination
45 .fa-heart
25 .mls_logo
19 .95
7 .listing-info
6 .reset-list-search
6 .hidden-curtain
5 .open-house-flag
5 .curtained
4 .mobile-list-search-result-link
3 .previous_page
3 .listing-thumb
2 .search-bottom-bar
2 .list-search-flag
2 .extra-padding-for-fixed-search-bar
1 .status-type
1 .stand-alone-mobile-search
1 .sold-home-flag
1 .save-search-btn
1 .pagination-container
1 .next_page
1 .mobile-no-results
1 .listing-user-preferences
1 .header-top-bar
1 .amenities
0 .js-mobile-save-search
0 .information-bar-search-details
0 .img-icon
0 .hot-neighborhoods-link
0 .gap
0 .current-search-information-bar
0 .current-search-filters-set
0 .basic-pagination-styles;
0 .basic-pagination-styles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment