Recursive Delete PDF Print
Written by Frank Sfalanga   
Thursday, 20 May 2010

Sometimes I need to NOT delete some specific files but delete everything else.  I need to save '4878c' but delete '4878cc' - and I need to do this recursively.

for file in $( ls | grep -v '^4878c$'\
        | grep -v '^4878c.map$'\
        | grep -v '^4878c.qota1$'\
        | grep -v '^4878c.qtta1$'\
        | grep -v '^main.txt$'\
        | grep -v '^samp.txt$'\
        | grep -v '^tipresps$' ); do rm -rf $file; done
 

This deletes EVERYTHING except the 7 specific files I want to preserve.

 
Next >