Notes

Remove all files or directories except one

Posted by Dan on Thursday the 28th of April, 2016

To remove all directories except one specified:

ls | grep -v directory_name | xargs rm -rf

remove all files except one specified:

ls | grep -v file_name | xargs rm

Posted in: Linux