using find to find files but ignore lost+found

>> Tuesday, 19 September 2017

Because it took me a while to work this out and I know I'll never remember how I did it:

e.g.

/usr/bin/find /path/to/search/ -name "myfile_name_in_some_form*.tar.gz"  -not \( -path ".lost+found" -prune \) -print  -mtime +92 -exec ls {} \;


delete my backup files over 92 days old:

/usr/bin/find /backup/mydir/ -name "mybackupfile*.tar.gz"  -not \( -path ".lost+found" -prune \) -print  -mtime +92 -exec rm {} \;


An alternative:

/usr/bin/find /backup/mydir/ \! -readable -prune -o  -name "mybackupfile_*.tar.gz" -print  -mtime +92 -exec rm {} \;

0 comments:


  © Blogger template Simple n' Sweet by Ourblogtemplates.com 2009

Back to TOP