Last active
September 5, 2020 12:09
-
-
Save scriptype/d1dc28bddfca0f79f557c6df1428c8f6 to your computer and use it in GitHub Desktop.
Find unused tsx files
This file contains hidden or 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
# It will print all file names (without extension) | |
# and list all files (their full paths) that reference those files inside an import statement | |
# | |
# It may and most likely will find false negatives (files that are actually used), | |
# so double-checking those files before deleting them is needed. | |
find src -name '*.tsx' \ | |
| awk -F/ '{print $NF}' \ | |
| awk -F. '{print $1}' \ | |
| xargs -I _ sh -c "echo '\nFile: _' && grep --recursive --include='*.tsx' -isw 'from .\+_\"' src | awk '{ print $1 }' | cut -d':' -f1 | uniq" \ | |
| less |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment