Last active
January 6, 2018 02:37
-
-
Save jakebathman/e3bc17a0d28b246542f0afb3a8594b53 to your computer and use it in GitHub Desktop.
Various shell commands that I always have to look up
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
# Delete files based on a pattern | |
# The example below removes PDF files in nested directories, such as ./50/round_2/foo.pdf | |
# but would NOT remove the file ./50/packages/foo.pdf | |
find . -regextype posix-extended -regex ".*/round.*\.pdf" -exec rm {} + | |
# Delete a history item by its ID | |
history # get the ID (left-hand number) for the item you want to remove | |
history -d item_number | |
# Delete keys in redis matching some pattern, atomically | |
redis-cli KEYS "prefix:*" | xargs redis-cli DEL | |
# Delete files based on their modification time | |
# -mtime n is equivalent to saying "modified n*24 hours ago or before" (the + means "or before") | |
find . -mtime +90 -type f -print |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment