Delete multiple files that contain spaces based on age

I had a problem on a FTP server running Solaris 9 that had tons of old files and many of them had spaces in the names. How do you automate removing the old files (the real concern being the spaces in the filenames)? Most solutions recommend using -print0 in find or xargs -0, neither of which are options in Solaris 9.

This command removes any files older then 2 years old in the current directory:

find . -type f -mtime +730 | while read filename; do rm -f “$filename”; done





Please VOTE for this page at: ADD TO DEL.ICIO.US | ADD TO DIGG | ADD TO FURL | ADD TO NEWSVINE | ADD TO NETSCAPE | ADD TO REDDIT | ADD TO STUMBLEUPON | ADD TO TECHNORATI FAVORITES | ADD TO SQUIDOO | ADD TO WINDOWS LIVE | ADD TO YAHOO MYWEB | ADD TO ASK | ADD TO GOOGLE


1 Comment


  1. To remove empty directories quickly (relying on rmdir to not delete directories unless they are empty) that have spaces in them:

    find . -type d | while read foldername; do rmdir “$foldername”; done

    If there are empty folders inside of other folders then you would need to run this multiple times…

    Posted May 8, 2012, 9:45 am

Leave a reply