Thursday, June 21, 2012

Linux Shell Tips - rm exclude emulation

If you want to remove all files and sub-directories from directory exept some files you can use  rm and find combination as described below: :

rm -rf $(find . ! -wholename './web/index.php' ! -wholename './web/.htaccess' ! -name '.' ! -name 'web')

You can see more find power examples on  http://www.infoanda.com/resources/find.htm

No comments: