Skip to content

Instantly share code, notes, and snippets.

@jakebathman
Last active January 6, 2018 02:37
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 jakebathman/e3bc17a0d28b246542f0afb3a8594b53 to your computer and use it in GitHub Desktop.
Save jakebathman/e3bc17a0d28b246542f0afb3a8594b53 to your computer and use it in GitHub Desktop.
Various shell commands that I always have to look up
# 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