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 file?
Is there any command for that? rm -rf * gives the ease of deletion at one shot, but deletes even my favourite file/directory.
Thanks in advance
findcan be a very good friend:Explanation:
find * -maxdepth 0: select everything selected by*without descending into any directories-name 'b' -prune: do not bother (-prune) with anything that matches the condition-name 'b'-o -exec rm -rf '{}' ';': callrm -rffor everything elseBy the way, another, possibly simpler, way would be to move or rename your favourite directory so that it is not in the way: