Created
December 11, 2023 19:05
-
-
Save kellyfelkins/41f4de65b47d4d10636280d2f0cf91c3 to your computer and use it in GitHub Desktop.
crazy shell 1 liner - find module names in files ending in "chart" and grep all files to see of those are aliases or imported
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
# crazy shell command | |
find lib/dpi_web/live -name '*_chart.ex' | xargs ghead -q -n 1 | cut -d " " -f 2 | xargs -I % echo "echo '>>> %'; grep -R -E '(import|alias) %' lib/dpi_web/live;" | sh | |
# let's break it down | |
find lib/dpi_web/live -name '*_chart.ex' | |
# search for files like '*_chart.ex' starting in the lib/dpi_web/live directory | |
| xargs ghead -q -n 1 | |
# take the first line of those file, and don't tell me the name of the file | |
| cut -d " " -f 2 | |
# split that first line breaking on spaces, and return the 2nd item | |
| xargs -I % echo "echo '>>> %'; grep -R -E '(import|alias) %' lib/dpi_web/live;" | |
# echo, but don't execute some commands with the items from the previous command inserted | |
| sh | |
# execute those commands |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment