If we want to delete all files and directories we use, rm -rf *
.
But what if i want all files and directories be deleted at a shot, except one particular fi
If it's just one file, one simple way is to move that file to /tmp
or something, rm -Rf
the directory and then move it back. You could alias this as a simple command.
The other option is to do a find
and then grep
out what you don't want (using -v
or directly using one of find
s predicates) and then rm
ing the remaining files.
For a single file, I'd do the former. For anything more, I'd write something custom similar to what thkala said.