The Linux find command

Written by James McDonald

June 20, 2008

I’m putting this here so I can recall it for later

find -mtime +2 -type f -print -exec mv {} /home/user/old/ \;

Basically it does the following: Find all files where the File’s data was last modified more than 2 days ago and run the move command on each file to move them to the specified directory.

find -mtime +2 -type f -print -exec rm -f {} \;

This one removes any files older than 2 days from the current directory. Don’t do this in /usr/bin!

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

Docker on Fedora 32

Docker on Fedora 32

Commands to run to get moby-engine running on Fedora 32 # as root or sudo'd dnf install grubby grubby...

PDF Poster

PDF Poster

Start with a wide long image. This is just a screen shot of my desktop. widescreen.png Convert it to postscript using...