How to delete all but one file in linux directory March 15, 2010 by Kurt Turner ls *| grep -v FileName | xargs rm -rf Using this command you can delete all files except the one listed.