Created
July 11, 2019 15:41
-
-
Save lorey/e8850bd81008fef9f0c0bcca16b85275 to your computer and use it in GitHub Desktop.
Delete all files that contain a specific string via command line
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
# say we want to delete all files that contain the string "trash" | |
# source: https://stackoverflow.com/a/4529138 | |
# 1) create a file that lists all files to delete | |
find .cache/ | xargs grep -l "trash" | awk '{print "rm "$1}' > delete.sh | |
# 2) check for errors and stuff | |
vim delete.sh | |
# 3) make the file executable and execute | |
sudo chmod +x delete.sh | |
./delete.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment