This will find all files under the path "." which are older than 10 days, and delete them. If you wish to use the "rm" command instead, replace "-delete" with "-exec rm [options] {} \;"
The "-u USER" is optional if root user is used
Like the above, but runs a single rm command
Removes all *.swp files underneath the current directory. Replace "*.swp" with your file pattern(s).
While `echo rm * | batch` might seem to work, it might still raise the load of the system since `rm` will be _started_ when the load is low, but run for a long time. My proposed command executes a new `rm` execution once every minute when the load is small. Obviously, load could also be lower using `ionice`, but I still think this is a useful example for sequential batch jobs. Show Sample Output
Removes directories which are less than 1028KB total. This works for systems where blank directories are 4KB. If a directory contains 1 MB (1024KB) or less, it will remove the directory using a path relative to the directory where the command was initially executed (safer than some other options I found).
Adjust the 1028 value for your needs.
It would be helpful to test the results before proceeding with the removal. Simply run all but the last two commands to see a list of what will be removed:
du | awk '{if($1<1028)print;}' | cut -d $'\t' -f 2-
If you're unsure what size a blank folder is, test it like this:
mkdir test; du test; rmdir test
simulation test to see which files would be deleted: find . -name "*.bak" -type f
We had a number of git tags named similarly to: 2016.12.13.devel.feature 2016.12.14.master.release But we have multiple developers making commits and tags for testing purposes. I wanted to reduce the number of tags that displayed on our cloud hosting server when doing a deployment.
This begins recursively looking at dot files starting from "./path_to_dir". Then it prints out the names of those files. If you are satisfied with the list of files discovered then you can delete them like so `find ./path_to_dir -type f -name '.*' -exec rm '{}' \;` which executes the removal program against each of those names previously printed. This is useful when you want to remove thumbnail files on Mac OSX/Windows or simply want to reset an app's configuration on Linux.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: